Get Android app name

Normally, ADT eclipse auto create string app_name in your strings.xml. And set it in manifest like this:

<application
  android:name=".MyApp"
  android:icon="@drawable/ic_launcher_icon"
  android:label="@string/app_name"
  android:debuggable="true">

Method 1: If that, you can easily get app name by:

String applicationName = getResources().getString(R.string.app_name);

Method 2: But if you didn’t specify it in resource xml, you can also get app name by:

int stringId = context.getApplicationInfo().labelRes;
return context.getString(stringId);

Leave a comment