Android examples for App:APK File
Gets the application name specified by android:label in the AndroidManifest.xml.
//package com.java2s; import android.content.Context; import android.support.annotation.NonNull; public class Main { /**/*from w w w.ja v a 2 s .c o m*/ * Gets the application name specified by android:label in the AndroidManifest.xml. * It does not work if you hard-code your app name like android:label="MyApp". * Use a string resource such as @string/app_name. * @param context the context * @return application name */ public static String getApplicationName(@NonNull Context context) { int stringId = context.getApplicationInfo().labelRes; return context.getString(stringId); } }