How to get a list of installed android applications and pick one to run

后端 未结 19 1834
误落风尘
误落风尘 2020-11-21 06:26

I asked a similar question to this earlier this week but I\'m still not understanding how to get a list of all installed applications and then pick one to run.

I\'v

19条回答
  •  无人共我
    2020-11-21 07:27

    Get All the apps:

        PackageManager pm = getContext().getPackageManager();
        List apps = pm.getInstalledApplications(0);
    

    Check if installed app then open:

    if((app.flags & (ApplicationInfo.FLAG_UPDATED_SYSTEM_APP | ApplicationInfo.FLAG_SYSTEM)) > 0) {
                    String app_package = app.packageName;
    Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(app_package);
    context.startActivity(launchIntent);
    

提交回复
热议问题