當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。