アクション「VIEW」とカテゴリ「BROWSABLE」でインテントをフィルタリングできるすべてのアプリをデバイスで検索する方法を探していますか?
次のリンクを見つけて、すべてのインテント フィルターを一覧表示する方法を学びましたが、前述のパラメーターのみを持つものだけを一覧表示するにはどうすればよいですか?
ACTION_SEND インテントで特定のアプリをフィルタリングする方法 (およびアプリごとに異なるテキストを設定する方法)
前もって感謝します
アクション「VIEW」とカテゴリ「BROWSABLE」でインテントをフィルタリングできるすべてのアプリをデバイスで検索する方法を探していますか?
次のリンクを見つけて、すべてのインテント フィルターを一覧表示する方法を学びましたが、前述のパラメーターのみを持つものだけを一覧表示するにはどうすればよいですか?
ACTION_SEND インテントで特定のアプリをフィルタリングする方法 (およびアプリごとに異なるテキストを設定する方法)
前もって感謝します
This code should do more or less what you want. The main problem is that I don't think you will find any activity that filters for CATEGORY_BROWSABLE
without also requiring data of a specific type. I tried it on my phone and I didn't get anything useful until I added the setData()
call on the Intent.
PackageManager manager = getPackageManager();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
// NOTE: Provide some data to help the Intent resolver
intent.setData(Uri.parse("http://www.google.com"));
// Query for all activities that match my filter and request that the filter used
// to match is returned in the ResolveInfo
List<ResolveInfo> infos = manager.queryIntentActivities (intent,
PackageManager.GET_RESOLVED_FILTER);
for (ResolveInfo info : infos) {
ActivityInfo activityInfo = info.activityInfo;
IntentFilter filter = info.filter;
if (filter != null && filter.hasAction(Intent.ACTION_VIEW) &&
filter.hasCategory(Intent.CATEGORY_BROWSABLE)) {
// This activity resolves my Intent with the filter I'm looking for
String activityPackageName = activityInfo.packageName;
String activityName = activityInfo.name;
System.out.println("Activity "+activityPackageName + "/" + activityName);
}
}
}