の助けを借りて、Launcherにあるすべてのアプリケーションを取得することができますIntent.CATEGORY_LAUNCHER
。
したがって、テスト用にテストアクティビティを作成しました。このアクティビティにはボタンが1つ含まれています。ボタンを押すと、デバイスにアプリケーションが表示されます。
NOTE: `it should not display specific. for example i needed only Browser it should display all browser applications.`
私はこのようにして小さなコードを試しました:
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_BROWSER);
List<ResolveInfo> mainLauncherList = getPackageManager().queryIntentActivities(intent, 0);
System.out.println("the list iss = " +mainLauncherList);
}
});
リストは、単一のブラウザである1つのブラウザのみを返します。