Java Code Examples for android.content.pm.PackageManager.getApplicationLabel()

The following are Jave code examples for showing how to use getApplicationLabel() of the android.content.pm.PackageManager class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GCSApp   File: EaseUI.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 2
Project: Tribe   File: EaseUI.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 3
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AppUtils.java   View Source Code Vote up 5 votes
@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;
    }
}
 
Example 4
Project: DroidPlugin   File: ApkItem.java   View Source Code Vote up 5 votes
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;
}
 
Example 5
Project: Bailan   File: AppInfoUtils.java   View Source Code Vote up 5 votes
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);
}
 
Example 6
Project: AgentWeb   File: AgentWebUtils.java   View Source Code Vote up 5 votes
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;
}
 
Example 7
Project: AgentWebX5   File: DefaultWebClient.java   View Source Code Vote up 5 votes
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;
}
 
Example 8
Project: Batch-Uninstaller   File: PackageUtils.java   View Source Code Vote up 5 votes
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;
    }
}
 
Example 9
Project: rongyunDemo   File: UpdateService.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: AirQuickUtils   File: AirSystem.java   View Source Code Vote up 5 votes
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)");
}
 
Example 11
Project: Xndroid   File: BookmarkSettingsFragment.java   View Source Code Vote up 5 votes
@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;
}
 
Example 12
Project: ServiceDownLoadApp-master   File: UpdateService.java   View Source Code Vote up 5 votes
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;
}
 
Example 13
Project: Auto.js   File: AppUtils.java   View Source Code Vote up 5 votes
@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;
    }
}
 
Example 14
Project: letv   File: ShareCompat.java   View Source Code Vote up 5 votes
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;
}
 
Example 15
Project: FancyView   File: OpeningStartAnimation.java   View Source Code Vote up 5 votes
private OpeningStartAnimation(Context context) {
    super(context);
    PackageManager packageManager = context.getPackageManager();
     mDrawable = context.getApplicationInfo().loadIcon(packageManager);
     appName = (String) packageManager.getApplicationLabel(context.getApplicationInfo());
     appStatement = "Sample Statement";
}
 
Example 16
Project: jackknife   File: ApkUtils.java   View Source Code Vote up 5 votes
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);
}
 
Example 17
Project: sealtalk-android-master   File: UpdateService.java   View Source Code Vote up 5 votes
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;
}
 
Example 18
Project: boohee_v5.6   File: ShareCompat.java   View Source Code Vote up 5 votes
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;
}
 
Example 19
Project: GongXianSheng   File: CommonUtils.java   View Source Code Vote up 5 votes
/**
 * 获取应用名称
 * @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;
}
 
Example 20
Project: ResourceInspector   File: RIChromeDiscoveryHandler.java   View Source Code Vote up 4 votes
private CharSequence getAppLabel() {
    PackageManager pm = context.getPackageManager();
    return pm.getApplicationLabel(context.getApplicationInfo());
}