get application name from package name

You can use PackageManager class to obtain ApplicationInfo:

final PackageManager pm = getApplicationContext().getPackageManager();
ApplicationInfo ai;
try {
    ai = pm.getApplicationInfo( this.getPackageName(), 0);
} catch (final NameNotFoundException e) {
    ai = null;
}
final String applicationName = (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)");

This would return the application name as defined in <application> tag of its manifest.

Leave a Comment