Unless specified in the strings.xml / hardcoded file in AndroidManifest.xml for any reason, such as android: label = "MyApp"
public String getAppLable(Context context) { PackageManager packageManager = context.getPackageManager(); ApplicationInfo applicationInfo = null; try { applicationInfo = packageManager.getApplicationInfo(context.getApplicationInfo().packageName, 0); } catch (final NameNotFoundException e) { } return (String) (applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo) : "Unknown"); }
Or, if you know the String resource identifier, you can directly get it through
getString(R.string.appNameID);
Vinayak Bevinakatti May 08 '13 at 3:09 pm 2013-05-08 15:09
source share