获取Activity名字,获取Activity标签
public static CharSequence getLabel(Context context, String pkgName, String clsName) {
if (context == null || pkgName == null) {
Log.w(TAG, "getLabel,pkgName=" + pkg + "clsName=" + clsName);
return null;
}
ActivityInfo info = null;
try {
info = context.getPackageManager().getActivityInfo(new ComponentName(pkgName, clsName), PackageManager.MATCH_DEFAULT_ONLY);
if (info.labelRes > 0 && info.exported) {
String str = context.getString(info.labelRes);
if (str != null) {
return str;
}
}
return info.loadLabel(context.getPackageManager());
} catch (Exception e) {
Log.w(TAG, "getLabel,Exception="+ e.getMessage());
}
return null;
}