本文整理汇总了Java中android.content.pm.PackageManager.getApplicationLabel方法的典型用法代码示例。如果您正苦于以下问题:Java PackageManager.getApplicationLabel方法的具体用法?Java PackageManager.getApplicationLabel怎么用?Java PackageManager.getApplicationLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.pm.PackageManager
的用法示例。
在下文中一共展示了PackageManager.getApplicationLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAppName
import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
* check the application process name if process name is not qualified, then we think it is a service process and we will not init SDK
* @param pID
* @return
*/
private String getAppName(int pID) {
String processName = null;
ActivityManager am = (ActivityManager) appContext.getSystemService(Context.ACTIVITY_SERVICE);
List l = am.getRunningAppProcesses();
Iterator i = l.iterator();
PackageManager pm = appContext.getPackageManager();
while (i.hasNext()) {
ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo) (i.next());
try {
if (info.pid == pID) {
CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA));
// Log.d("Process", "Id: "+ info.pid +" ProcessName: "+
// info.processName +" Label: "+c.toString());
// processName = c.toString();
processName = info.processName;
return processName;
}
} catch (Exception e) {
// Log.d("Process", "Error>> :"+ e.toString());
}
}
return processName;
}
示例2: getAppName
import android.content.pm.PackageManager; //导入方法依赖的package包/类
@ScriptInterface
public String getAppName(String packageName) {
PackageManager packageManager = mContext.getPackageManager();
try {
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
CharSequence appName = packageManager.getApplicationLabel(applicationInfo);
return appName == null ? null : appName.toString();
} catch (PackageManager.NameNotFoundException e) {
return null;
}
}
示例3: ApkItem
import android.content.pm.PackageManager; //导入方法依赖的package包/类
ApkItem(PackageManager pm, PackageInfo info, String path) {
try {
icon = pm.getApplicationIcon(info.applicationInfo);
} catch (Exception e) {
icon = pm.getDefaultActivityIcon();
}
title = pm.getApplicationLabel(info.applicationInfo);
versionName = info.versionName;
versionCode = info.versionCode;
apkfile = path;
packageInfo = info;
}
示例4: getAppLabel
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static CharSequence getAppLabel(Context context, String apkFilepath) {
PackageManager pm = context.getPackageManager();
PackageInfo pkgInfo = getPackageInfo(context, apkFilepath);
if (pkgInfo == null) {
return null;
}
ApplicationInfo appInfo = pkgInfo.applicationInfo;
if (Build.VERSION.SDK_INT >= 8) {
appInfo.sourceDir = apkFilepath;
appInfo.publicSourceDir = apkFilepath;
}
return pm.getApplicationLabel(appInfo);
}
示例5: getApplicationName
import android.content.pm.PackageManager; //导入方法依赖的package包/类
static String getApplicationName(Context context) {
PackageManager packageManager = null;
ApplicationInfo applicationInfo = null;
try {
packageManager = context.getApplicationContext().getPackageManager();
applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
applicationInfo = null;
}
String applicationName =
(String) packageManager.getApplicationLabel(applicationInfo);
return applicationName;
}
示例6: getApplicationName
import android.content.pm.PackageManager; //导入方法依赖的package包/类
private String getApplicationName(Context context) {
PackageManager packageManager = null;
ApplicationInfo applicationInfo = null;
try {
packageManager = context.getApplicationContext().getPackageManager();
applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
applicationInfo = null;
}
String applicationName =
(String) packageManager.getApplicationLabel(applicationInfo);
return applicationName;
}
示例7: getAppName
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static String getAppName(Context context, String package_name) {
PackageManager pm = context.getPackageManager();
try {
return (String) pm.getApplicationLabel(pm.getApplicationInfo(package_name, PackageManager.GET_META_DATA));
} catch (PackageManager.NameNotFoundException e) {
return null;
}
}
示例8: getApplicationName
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public String getApplicationName() {
PackageManager packageManager = null;
ApplicationInfo applicationInfo = null;
try {
packageManager = getApplicationContext().getPackageManager();
applicationInfo = packageManager.getApplicationInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
applicationInfo = null;
}
String applicationName =
(String) packageManager.getApplicationLabel(applicationInfo);
return applicationName;
}
示例9: getApplicationNameByContext
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static String getApplicationNameByContext() {
final PackageManager pm = AirQuickUtils.getContext().getPackageManager();
ApplicationInfo ai;
try {
ai = pm.getApplicationInfo(AirQuickUtils.getContext().getPackageName(), 0);
} catch (final PackageManager.NameNotFoundException e) {
ai = null;
}
return (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)");
}
示例10: getTitle
import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Nullable
private static String getTitle(@NonNull Activity activity, @NonNull String packageName) {
PackageManager pm = activity.getPackageManager();
try {
ApplicationInfo info = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
CharSequence title = pm.getApplicationLabel(info);
if (title != null) {
return title.toString();
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return null;
}
示例11: getApplicationName
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public String getApplicationName() {
PackageManager packageManager = null;
ApplicationInfo applicationInfo = null;
try {
packageManager = getApplicationContext().getPackageManager();
applicationInfo = packageManager.getApplicationInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
applicationInfo = null;
}
String applicationName =
(String) packageManager.getApplicationLabel(applicationInfo);
return applicationName;
}
示例12: getCallingApplicationLabel
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public CharSequence getCallingApplicationLabel() {
CharSequence charSequence = null;
if (this.mCallingPackage != null) {
PackageManager pm = this.mActivity.getPackageManager();
try {
charSequence = pm.getApplicationLabel(pm.getApplicationInfo(this.mCallingPackage, 0));
} catch (NameNotFoundException e) {
Log.e(TAG, "Could not retrieve label for calling application", e);
}
}
return charSequence;
}
示例13: OpeningStartAnimation
import android.content.pm.PackageManager; //导入方法依赖的package包/类
private OpeningStartAnimation(Context context) {
super(context);
PackageManager packageManager = context.getPackageManager();
mDrawable = context.getApplicationInfo().loadIcon(packageManager);
appName = (String) packageManager.getApplicationLabel(context.getApplicationInfo());
appStatement = "Sample Statement";
}
示例14: getUninstalledApkLabel
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static CharSequence getUninstalledApkLabel(Context context, String apkPath) {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = getUninstalledApkPackageInfo(context, apkPath);
if (packageInfo == null) {
return null;
}
ApplicationInfo applicationInfo = packageInfo.applicationInfo;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
applicationInfo.sourceDir = apkPath;
applicationInfo.publicSourceDir = apkPath;
}
return packageManager.getApplicationLabel(applicationInfo);
}
示例15: getAppName
import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
* 获取应用名称
* @param context
* @return
*/
public static String getAppName(Context context) {
PackageManager packageManager = null;
ApplicationInfo applicationInfo = null;
try {
packageManager = context.getApplicationContext().getPackageManager();
applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
applicationInfo = null;
}
String applicationName =
(String) packageManager.getApplicationLabel(applicationInfo);
return applicationName;
}