Android examples for App:APK Information
get Activity Label
//package com.java2s; import android.content.ComponentName; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static String getActivityLabel(Context context, ComponentName name) {/*from w w w. ja v a 2s. co m*/ PackageManager pkgManager = context.getPackageManager(); if (pkgManager == null) return null; ActivityInfo activityInfo = getActivityInfo(pkgManager, name); if (activityInfo == null) return null; CharSequence cs = activityInfo.loadLabel(pkgManager); if (cs == null) return null; return cs.toString(); } public static ActivityInfo getActivityInfo(PackageManager pkgManager, ComponentName name) { if (pkgManager == null) return null; try { ActivityInfo activityInfo = pkgManager.getActivityInfo(name, 0); if (activityInfo == null) return null; return activityInfo; } catch (NameNotFoundException e) { e.printStackTrace(); } return null; } }