特定のintent-filterが設定されているアプリ一覧が欲しいなぁと思った際に、
どうやって取得するのかわからなかったので、調べました。
具体的にはIntentを作成し、PackageManagerに、そのIntentに該当するActivityを取得するメソッドqueryIntentActivitiesを実行するという方法です。
PackageManager pm = getPackageManager();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
HashMap<String, String> maps = new HashMap<String, String>();
for (ResolveInfo app : apps) {
ApplicationInfo info = app.activityInfo.applicationInfo;
maps.put(info.loadLabel(pm).toString(), info.packageName);
}
以上でーす。
