Pls i need android code to convert package name to application name (Assuming i already have the package name e.g. String name = "com.skgames.trafficrider")
Asked
Active
Viewed 1,088 times
-2
-
1What do you consider the "application name" to be? – CommonsWare Apr 13 '17 at 20:12
-
Do you want "trafficrider" or is "com.skgames.trafficrider" the package in which the application is in – Ishnark Apr 13 '17 at 20:12
-
i have multiple strings of application packages i want to convert them to their actual application names – vitus Apr 13 '17 at 20:13
-
com.skgames.trafficrider is a package name. i need codes to convert it to its actual application name @ishnark. Thanks for the quick reply – vitus Apr 13 '17 at 20:15
2 Answers
0
put package name to this function and get AppName (App Label)
public String appName(String pack){
String Name = null;
try{
PackageManager packManager = context.getPackageManager();
ApplicationInfo app = context.getPackageManager().getApplicationInfo(pack, 0);
Name = packManager.getApplicationLabel(app).toString();
}
catch(Exception e){
e.printStackTrace();
}
return Name;
}

Elias Fazel
- 2,093
- 16
- 20
0
Try to use next code:
ApplicationInfo ai;
try {
ai = pm.getApplicationInfo("com.skgames.trafficrider", 0);
} catch (final NameNotFoundException e) {
ai = null;
}
final String applicationName = (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)");

Sergio
- 27,326
- 8
- 128
- 149