I want to add my activity (com.myapp.launcher.settings) to an empty ArrayList.
ArrayList<ResolveInfo> selectedApps = new ArrayList<ResolveInfo>();
selectedApps.add(/*WHAT GOES IN HERE?*/);
But I don't know how to get a ResolveInfo object with my activity.
I managed to make a workaround that loops through all apps to find my activity. But it's not very efficient or practical:
// Get an array list of all apps
ArrayList<ResolveInfo> allApps = (ArrayList<ResolveInfo>) pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
for(final ResolveInfo app : allApps) {
// If it's name is "com.myapp.launcher.settings" add it
if(app.activityInfo.name.equals("com.myapp.launcher.settings")) {
selectedApps.add(app);
}
}
Just use resolveActivity
with an explicit Intent
. Probably something like this:
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.myapp", "com.myapp.launcher.settings"));
ResolveInfo app = pm.resolveActivity(intent, 0);
selectedApps.add(app);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With