我想要獲取Android L中的所有默認應用程序。我使用了波紋管代碼,但他們給了我一個錯誤的解決方案。讓我先看看我的代碼在Android中顯示錯誤的默認應用程序列表L
private void getMyAppLauncherDefault() {
final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN);
filter.addCategory(Intent.CATEGORY_HOME);
List<IntentFilter> filters = new ArrayList<IntentFilter>();
filters.add(filter);
List<ComponentName> activities = new ArrayList<ComponentName>();
final PackageManager packageManager = (PackageManager) getPackageManager();
packageManager.getPreferredActivities(filters, activities, null);
for (ComponentName activity : activities) {
Log.d(TAG,"======packet default:==="+activity.getPackageName());
}
}
而這是日誌。日誌在com.google.android.googlequicksearchbox
和com.vlingo.midas
之間顯示錯誤結果。他們都是語音應用程序,但我默認設置了com.google.android.googlequicksearchbox
。我不知道爲什麼日誌顯示com.vlingo.midas
。我該如何解決它?由於
16:02:44.817 /com.exam D/Sample: ======packet default:===com.sec.android.gallery3d
16:02:44.827 /com.exam D/Sample: ======packet default:===com.android.mms
16:02:44.827 /com.exam D/Sample: ======packet default:===com.android.mms
16:02:44.827 /com.exam D/Sample: ======packet default:===com.vlingo.midas
16:02:44.827 /com.exam D/Sample: ======packet default:===com.sec.android.app.sbrowser
16:02:44.827 /com.exam D/Sample: ======packet default:===com.sec.android.gallery3d
16:02:44.827 /com.exam D/Sample: ======packet default:===com.android.mms
16:02:44.827 /com.exam D/Sample: ======packet default:===com.sec.android.app.launcher
16:02:44.827 /com.exam D/Sample: ======packet default:===com.sec.android.app.sbrowser
16:02:44.827 /com.exam D/Sample: ======packet default:===com.android.mms
16:02:44.827 /com.exam D/Sample: ======packet default:===com.google.android.googlequicksearchbox
16:02:44.827 /com.exam D/Sample: ======packet default:===com.sec.android.app.sbrowser
16:02:44.827 /com.exam D/Sample: ======packet default:===com.sec.android.gallery3d
16:02:44.827 /com.exam D/Sample: ======packet default:===com.android.mms
16:02:44.827 /com.exam D/Sample: ======packet default:===com.google.android.apps.plus
'com.vlingo.midas'很可能支持一個額外的過濾器,爲此它顯示出來。用包名稱打印相應的過濾器以檢查這一點。 – F43nd1r
@ F43nd1r:我們如何打印? 「過濾器」大小隻是1,而「過濾器」大小是4.但我無法打印過濾器的名稱 – Jame
可能是com.vlingo.midas是默認用於不同目的/應用程序。 –