android detail of intalled application
-
20-06-2021 - |
Domanda
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.
Soluzione
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/
Altri suggerimenti
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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow