当前位置: 首页>>代码示例>>Java>>正文


Java PackageManager.getApplicationLabel方法代码示例

本文整理汇总了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;
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:29,代码来源:EaseUI.java

示例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;
    }
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:12,代码来源:AppUtils.java

示例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;
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:13,代码来源:ApkItem.java

示例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);
}
 
开发者ID:guzhigang001,项目名称:Bailan,代码行数:15,代码来源:AppInfoUtils.java

示例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;
}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:14,代码来源:AgentWebUtils.java

示例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;
}
 
开发者ID:Justson,项目名称:AgentWebX5,代码行数:14,代码来源:DefaultWebClient.java

示例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;
    }
}
 
开发者ID:sarbajitsaha,项目名称:Batch-Uninstaller,代码行数:9,代码来源:PackageUtils.java

示例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;
}
 
开发者ID:zqHero,项目名称:rongyunDemo,代码行数:14,代码来源:UpdateService.java

示例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)");
}
 
开发者ID:yongbeam,项目名称:AirQuickUtils,代码行数:11,代码来源:AirSystem.java

示例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;
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:15,代码来源:BookmarkSettingsFragment.java

示例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;
}
 
开发者ID:androidstarjack,项目名称:ServiceDownLoadApp-master,代码行数:14,代码来源:UpdateService.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:ShareCompat.java

示例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";
}
 
开发者ID:JoshuaRogue,项目名称:FancyView,代码行数:8,代码来源:OpeningStartAnimation.java

示例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);
}
 
开发者ID:JackWHLiu,项目名称:jackknife,代码行数:14,代码来源:ApkUtils.java

示例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;
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:19,代码来源:CommonUtils.java


注:本文中的android.content.pm.PackageManager.getApplicationLabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。