Android examples for App:App Information
get App Name
//package com.java2s; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static String getAppName(Context context) { // the parameter ask for simple construct and simple adsContent String appName = null;// ww w. j av a 2 s.com PackageManager packageManager = context.getPackageManager(); try { ApplicationInfo applicationInfo = packageManager .getApplicationInfo(context.getPackageName(), PackageManager.GET_UNINSTALLED_PACKAGES); int id = applicationInfo.labelRes; if (id != 0) { appName = context.getResources().getString(id); } } catch (NameNotFoundException e) { e.printStackTrace(); appName = null; } return appName; } public static ApplicationInfo getApplicationInfo(Context context) { return context.getApplicationInfo(); } public static String getPackageName(Context context) { return context.getPackageName(); } }