How do I get a list of applications installed on the device, select them, and run them?

Asked 1 years ago, Updated 1 years ago, 138 views

I asked a similar question this week. I still don't understand. How do you get all the applications installed on your device? Can I get it? And how do you do what you choose?

Intent intent = new Intent(ACTION_MAIN);
intent.addCategory(CATEGORY_LAUNCHER);

I tried it like this, but I only saw the basic app.

I know I can get a list of installed apps from Package Manager, but how do I run it?

android android-intent

2022-09-22 22:23

1 Answers

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0)

This way, you can get a list of applications. And if you want to run an application, After you know the name of the package you want to run,

Intent intent = context.getPackageManager().getLaunchIntentForPackage("ParkageName");
startActivity(intent);

You can run the activity this way.


2022-09-22 22:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.