Android - How to Get Application Name? (Not Package Name)

How to get Application name from package name in android?

You can get Application name from package using following code

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

android - Installed app section shows package name instead of app name for my own application

the application name (label) should be within the application tag and not the activity.

<application 
android:label="@string/app_name"
>
....

How to get the name of the application in android?

you can use PackageManager#getApplicationInfo()

For getting the Application Name for all packages installed in the device.
Assuming you have your current Context object ctx

Resources appR = ctx.getResources();
CharSequence txt = appR.getText(appR.getIdentifier("app_name",
"string", ctx.getPackageName()));

Get app name from package name in android

You need to use PackageManager to get detailed information about installed packages.

PackageManager packageManager = context.getPackageManager();
ApplicationInfo applicationInfo = null;
try {
applicationInfo = packageManager.getApplicationInfo(packageName, 0);
} catch (final NameNotFoundException e) {}
final String title = (String)((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");


Related Topics



Leave a reply



Submit