0

I want to get ApplicationInfo of an app by app uid. Specially I want to get label name of application (the name under application icon).

I know I can list all of installed application and compare this uid with their uid and find label name of application with this uid. But is there a better solution?

MR.Iraji
  • 56
  • 9
  • https://stackoverflow.com/questions/5841161/get-application-name-from-package-name – AskNilesh Jan 06 '18 at 07:25
  • With the solution in this post I Must get package name by packageManager.getNameForUid(uid) method at first and then get ApplicationInfo of app by packageManager.getApplicationInfo(packageName, 0) method and then label name of application by packageManager.getApplicationLabel(applicationInfo) method. But is there a more straightforward solution? – MR.Iraji Jan 06 '18 at 07:45

1 Answers1

0

Assuming you already have the pid of the application:

PackageManager pm = getApplicationContext().getPackageManager();
String packageName = pm.getNameForUid(pid);
PackageInfo pInfo = pm.getPackageInfo(packageName, 0);
String appLabel = pm.getApplicationLabel(pInfo.applicationInfo);
Bilko
  • 338
  • 7
  • 12