2

I have already looked around and what I've seen was getting the package names or getting the App names and storing it in an Array List.

But what if I have an Array list of App names and I would like to get their package name counterpart ?

how do I do it ?

Janvi Vyas
  • 732
  • 5
  • 16
ZYX
  • 23
  • 7

1 Answers1

0

PackageManager can be used for the same.

PackageManager pm = context.getPackageManager();
List<ApplicationInfo> l = pm.getInstalledApplications(PackageManager.GET_META_DATA);
String canonicalName = “”;
for (ApplicationInfo ai : l){
String n = (String)pm.getApplicationLabel(ai);
if (n.contains(name) || name.contains(n)){
        canonicalName = ai.packageName; // retrieve package name here
    }
}
Aks4125
  • 4,522
  • 4
  • 32
  • 48