Ophy
Ophy

Reputation: 81

PackageManager.getInstalledApplications(0); in Android 7.0

My problem is that I use package manager to list all the installed applications

final PackageManager pm = parentActivity.getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(0);

With this code I can list successfully all the applications in other versions of android except in Android 7.0 (which only list the app that I'm using), can anyone knows why this is happening and how to solve it?

Upvotes: 1

Views: 2076

Answers (1)

Vikasdeep Singh
Vikasdeep Singh

Reputation: 21766

Try the below code. It is working fine for me:

final PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(0);

for (ApplicationInfo applicationInfo : packages) {
    Log.d("APP_INFO", "App: " + applicationInfo.name + " Package: " + applicationInfo.packageName);
}

Tested on Android 6, 7 and 8

Hope this will help!

Upvotes: 1

Related Questions