PackageManager getApplicationInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PackageManager getApplicationInfo method.

This code example shows how to use the following methods:checkSignatures, getApplicationInfo
This code example shows how to use the following methods:getApplicationInfo, getApplicationLabel
    private CharSequence getAppName(String packageName) {
        final PackageManager pm = mContext.getPackageManager();
        ApplicationInfo ai;
 
        try { 
            ai = pm.getApplicationInfo(packageName, 0);
        } catch (final NameNotFoundException e) {
            ai = null;
        } 
 
        if (ai != null) {
            return pm.getApplicationLabel(ai);
        } 
        return null; 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getApplicationInfo
		return pContext.getPackageName();
	} 
 
	public static String getApkFilePath(final Context pContext) throws NameNotFoundException {
		final PackageManager packMgmr = pContext.getPackageManager();
		return packMgmr.getApplicationInfo(SystemUtils.getPackageName(pContext), 0).sourceDir;
	} 
 
	private static PackageInfo getPackageInfo(final Context pContext) {
		try { 
			return pContext.getPackageManager().getPackageInfo(pContext.getPackageName(), 0);
		} catch (final NameNotFoundException e) {
			Debug.e(e);
			return null; 
		} 
	} 
 
	public static boolean hasSystemFeature(final Context pContext, final String pFeature) {
		try { 
			final Method PackageManager_hasSystemFeatures = PackageManager.class.getMethod("hasSystemFeature", new Class[] { String.class });
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getApplicationIcon, getApplicationInfo, getPackagesForUid
 
    public static Drawable getAppIcon(Context c, int uid) {
        PackageManager pm = c.getPackageManager();
        Drawable appIcon = c.getResources().getDrawable(
                android.R.drawable.sym_def_app_icon);
        String[] packages = pm.getPackagesForUid(uid);
 
        if (packages != null) {
            if (packages.length == 1) {
                try { 
                    ApplicationInfo appInfo = pm.getApplicationInfo(
                            packages[0], 0);
                    appIcon = pm.getApplicationIcon(appInfo);
                } catch (NameNotFoundException e) {
                    Log.e(c.getPackageName(),
                            "No package found matching with the uid " + uid);
                } 
            } 
        } else { 
            Log.e(c.getPackageName(), "Package not found for uid " + uid);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getApplicationInfo
 
        String packageName = context.getPackageName();
        PackageManager pm = context.getPackageManager();
        String dataDir = null;
        try { 
            dataDir = pm.getApplicationInfo(packageName, 0).dataDir;
        } catch (Exception e) {
            // Won't happen -- we know we're installed 
        } 
        return dataDir;
    } 
 
    private void setupBinDir() { 
        String dataDir = getDataDir(this);
        File binDir = new File(dataDir, "bin");
        if (!binDir.exists()) {
            try { 
                binDir.mkdir();
                chmod("755", binDir.getAbsolutePath());
            } catch (Exception e) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getApplicationInfo
     * available and that it's installed in the device's system image. 
     */ 
    public void testSettingsHookTestAppAvailable() throws Exception { 
        Context context = mSettings.getApplicationContext();
        PackageManager pm = context.getPackageManager();
        ApplicationInfo applicationInfo = pm.getApplicationInfo(PACKAGE_NAME, 0);
        assertTrue((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
    } 
 
    /** 
     * Test that the operator test activity has registered an intent-filter for 
     * an action named 'android.settings.OPERATOR_APPLICATION_SETTING'. 
     */ 
    public void testOperatorIntentFilter() { 
        boolean result = false;
        Context context = mSettings.getApplicationContext();
        PackageManager pm = context.getPackageManager();
        Intent intent = new Intent(INTENT_OPERATOR_HOOK);
        List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
        for (ResolveInfo resolveInfo : list) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getApplicationInfo, getApplicationLabel
 
    @CalledByNative 
    public static String getPackageLabel(Context context) {
        try { 
            PackageManager packageManager = context.getPackageManager();
            ApplicationInfo appInfo = packageManager.getApplicationInfo(context.getPackageName(),
                    PackageManager.GET_META_DATA);
            CharSequence label = packageManager.getApplicationLabel(appInfo);
            return  label != null ? label.toString() : "";
        } catch (NameNotFoundException e) {
            return ""; 
        } 
    } 
 
    @CalledByNative 
    public static String getPackageName(Context context) {
        String packageName = context != null ? context.getPackageName() : null;
        return packageName != null ? packageName : "";
    } 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getApplicationInfo, getApplicationLabel, getPackageInfo
This code example shows how to use the following methods:getApplicationInfo, getApplicationLabel
public final class Utility { 
	static final String PACKAGE = "com.steamcommunity.siplus.steamscreenshots";
 
	static String applicationLabel(PackageManager packageManager, String packageName) {
		try { 
			ApplicationInfo info = packageManager.getApplicationInfo(packageName, 0);
			return (String)(packageManager.getApplicationLabel(info));
		} catch (NameNotFoundException e) {
			return packageName;
		} 
	} 
 
	static void closeCloseable(Closeable closeable) {
		try { 
			closeable.close();
		} catch (IOException e) {}
	} 
 
	static void enableActionBarBack(Activity activity) {
		ActionBar actionBar = activity.getActionBar();
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getApplicationInfo, getPackageInfo
   */ 
  private static void loadPackageData(Context context) {
    if (context != null) {
      try { 
        PackageManager packageManager = context.getPackageManager();
        PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
        Constants.APP_PACKAGE = packageInfo.packageName;
        Constants.APP_VERSION = "" + packageInfo.versionCode;
         
        int buildNumber = loadBuildNumber(context, packageManager);
        if ((buildNumber != 0) && (buildNumber > packageInfo.versionCode)) {
          Constants.APP_VERSION = "" + buildNumber;
        } 
      }  
      catch (Exception e) {
        Log.e(TAG, "Exception thrown when accessing the package info:");
        e.printStackTrace();
      } 
    } 
  } 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related PackageManager getApplicationInfo Questions & Answers:

getApplicationInfo Method Overview
Retrieve all of the information we know about a particular package/application.
See Code Examples for other Android PackageManager Methods: