Android 清除默认launcher 改为其他的launcher

        //clear the current preferred launcher                ArrayList intentList = new ArrayList();                ArrayList cnList = new ArrayList();                mContext.getPackageManager().getPreferredActivities(intentList, cnList, null);                IntentFilter dhIF;                for(int i = 0; i < cnList.size(); i++) {                dhIF = intentList.get(i);                if(dhIF.hasAction(Intent.ACTION_MAIN) && dhIF.hasCategory(Intent.CATEGORY_HOME)) {                mContext.getPackageManager().clearPackagePreferredActivities(cnList.get(i).getPackageName());                //清除原有的默认launcher                }      // get all components and the best match     IntentFilter filter = new IntentFilter();     filter.addAction(Intent.ACTION_MAIN);     filter.addCategory(Intent.CATEGORY_HOME);     filter.addCategory(Intent.CATEGORY_DEFAULT);     final int N = list.size();     ComponentName[] set = new ComponentName[N];     int bestMatch = 0;     for (int i = 0; i < N; i++) {         ResolveInfo r = list.get(i);         set[i] = new ComponentName(r.activityInfo.packageName, r.activityInfo.name);         if (r.activityInfo.packageName.equals(packageName)) {             bestMatch = r.match;             Log.d(TAG, "bestMatch: " + r.activityInfo.packageName);         }     }     // add the default launcher as the preferred launcher     ComponentName launcher = new ComponentName(packageName, className);     mContext.getPackageManager().addPreferredActivity(filter, bestMatch, set, launcher);

更多相关文章

  1. Android(安卓)去掉 Launcher3 里面默认的Google搜索条
  2. Android(安卓)Imageview 图片居左居右,自定义圆角
  3. Android(安卓): Your APK does not seem to be designed for tab
  4. notification
  5. android:password is deprecated: Use inputType instead
  6. Android】Android(安卓)apk默认安装位置设置
  7. android > tabHost > 微博布局风格
  8. Android修改默认控件焦点不highlight
  9. Android(安卓)默认应用安装在sd卡中 (>2.2)

随机推荐

  1. android:windowIsTranslucent 导致 Activ
  2. 史上最详细的Android(安卓)Studio系列教
  3. C++调用Android(安卓)与Android调用C++
  4. Android跨进程通信IPC之8——Binder驱动
  5. C++调用Android(安卓)与Android调用C++
  6. android:gravity 与android:layout_gravi
  7. Android(安卓)通过Android(安卓)SDK Mana
  8. Android渗透测试Android渗透测试入门教程
  9. android系统自带的样式(@android:style)
  10. 50个Android开发人员必备UI效果源码