List of usage examples for android.content.pm PackageManager getApplicationLabel
public abstract CharSequence getApplicationLabel(ApplicationInfo info);
From source file:Main.java
public static String getAppName(Context context, String packageName) { try {/* ww w . j a v a 2 s .c o m*/ PackageManager pm = context.getPackageManager(); ApplicationInfo info = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); return pm.getApplicationLabel(info).toString(); } catch (Exception e) { return ""; } }
From source file:Main.java
public static String getApplicationName(Context app) { PackageManager pm; ApplicationInfo ai;//www . j a v a2s . c o m try { pm = app.getPackageManager(); ai = pm.getApplicationInfo(app.getPackageName(), 0); return pm.getApplicationLabel(ai).toString(); } catch (Exception e) { e.printStackTrace(); return app.getPackageName(); } }
From source file:Main.java
public static String getAppName(Context context) { try {/*w ww . j a v a2s. c o m*/ PackageManager packageManager = context.getPackageManager(); ApplicationInfo appInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); return (String) packageManager.getApplicationLabel(appInfo); } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:Main.java
public static String getAppName(Context context) { String appName = null;/*from www . ja v a2 s. com*/ try { PackageManager packageManager = context.getPackageManager(); ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); appName = packageManager.getApplicationLabel(applicationInfo).toString(); Log.i("liweiping", "appName = " + appName); } catch (NameNotFoundException e) { e.printStackTrace(); } return appName; }
From source file:Main.java
public static String getApplicationName(Context ctx) { ApplicationInfo ai;//from w w w . j a v a 2s . c om try { Context appContext = ctx.getApplicationContext(); assert appContext != null; final PackageManager pm = appContext.getPackageManager(); assert pm != null; ai = pm.getApplicationInfo(ctx.getPackageName(), 0); return (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)"); } catch (Exception ignored) { } return null; }
From source file:org.microg.gms.auth.AuthManagerServiceImpl.java
private static CharSequence getPackageLabel(String packageName, PackageManager pm) { try {/*w w w.jav a 2s . c o m*/ return pm.getApplicationLabel(pm.getApplicationInfo(packageName, 0)); } catch (PackageManager.NameNotFoundException e) { return packageName; } }
From source file:Main.java
public static String getAppName(Context context, String packageName) { PackageManager pm = context.getPackageManager(); String appName = null;//w w w. ja v a 2s .c o m try { ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, 0); appName = String.valueOf(pm.getApplicationLabel(applicationInfo)); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return appName; }
From source file:Main.java
public static String getAppName(Context context) { PackageManager packageManager = context.getPackageManager(); try {//from w ww .j ava 2 s. c o m ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); appName = (String) packageManager.getApplicationLabel(applicationInfo); if (appName == null) appName = "unknown"; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return appName; }
From source file:Main.java
public static String getApplicationName(final Context context) { String appName = ""; PackageManager packageManager = context.getPackageManager(); try {/* w w w . j av a 2s .co m*/ ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); appName = packageManager.getApplicationLabel(applicationInfo).toString(); } catch (NameNotFoundException e) { e.printStackTrace(); } return appName; }
From source file:Main.java
public static void delShortcutFromDesktop(Context paramContext, String packageName, String cls, String appName) {/*from w w w . j a v a2s . com*/ Intent localIntent1 = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT"); String str = appName; PackageManager localPackageManager = paramContext.getPackageManager(); int i = 8320; try { ApplicationInfo localApplicationInfo = localPackageManager.getApplicationInfo(packageName, i); if (str == null) str = localPackageManager.getApplicationLabel(localApplicationInfo).toString(); localIntent1.putExtra("android.intent.extra.shortcut.NAME", str); ComponentName localComponentName = new ComponentName(packageName, cls); Intent localIntent2 = new Intent(Intent.ACTION_MAIN).setComponent(localComponentName); localIntent2.addCategory(Intent.CATEGORY_LAUNCHER); localIntent1.putExtra("android.intent.extra.shortcut.INTENT", localIntent2); paramContext.sendBroadcast(localIntent1); return; } catch (PackageManager.NameNotFoundException localNameNotFoundException) { while (true) localNameNotFoundException.printStackTrace(); } }