is there a way to get details about applications installed in the device? I want to implement an app which can have at least names of installed applications. thanks in advance.

有帮助吗?

解决方案

You can use the PackageManager:

final PackageManager pm = getPackageManager();
//get a list of installed apps.
    List<ApplicationInfo> packages = pm
            .getInstalledApplications(PackageManager.GET_META_DATA);

    for (ApplicationInfo packageInfo : packages) {

        Log.d(TAG, "Installed package :" + packageInfo.packageName);
        Log.d(TAG, "Launch Activity :"
                        + pm.getLaunchIntentForPackage(packageInfo.packageName));
        Log.d(TAG, "Application name :" + pm.getApplicationLabel(packageInfo));

    }// the getLaunchIntentForPackage returns an intent that you can use with startActivity() 

Edit: You can use getApplicationLabel() to get the name, as shown above.

http://qtcstation.com/2011/02/how-to-launch-another-app-from-your-app/

其他提示

Here you go:

final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final List appsList = context.getPackageManager().queryIntentActivities(intent, 0);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top