Example usage for android.content.pm PackageManager GET_META_DATA

List of usage examples for android.content.pm PackageManager GET_META_DATA

Introduction

In this page you can find the example usage for android.content.pm PackageManager GET_META_DATA.

Prototype

int GET_META_DATA

To view the source code for android.content.pm PackageManager GET_META_DATA.

Click Source Link

Document

ComponentInfo flag: return the ComponentInfo#metaData data android.os.Bundle s that are associated with a component.

Usage

From source file:Main.java

private static int getUid(Context context) {
    try {// ww w .j a va  2s  . com
        int uid = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA).uid;
        return uid;
    } catch (Exception e) {

    }
    return 0;
}

From source file:Main.java

public static String readKey(Context context, String keyName) {
    try {//from  ww w.  j a  v  a  2 s  .  c  o m
        return context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA).metaData.getString(keyName);
    } catch (PackageManager.NameNotFoundException e) {
        return "Android";
    }
}

From source file:Main.java

public static String getAppMetaData(Context context, String key) {
    try {/* www.ja va 2s  . co m*/
        return context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA).metaData.getString(key);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}

From source file:Main.java

public static String getActivityMetaData(Activity activity, String key) {
    try {/*w  w w  .  j av  a 2 s.c om*/
        return activity.getPackageManager().getActivityInfo(activity.getComponentName(),
                PackageManager.GET_META_DATA).metaData.getString(key);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static int packageNameToResId(PackageManager packageManager, String packageName) {
    try {/*from   w  w w .ja  va  2s . c o  m*/
        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName,
                PackageManager.GET_META_DATA);
        return applicationInfo.icon;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return -1;
    }
}

From source file:Main.java

public static PackageInfo getApkInfo(Context context, String archiveFilePath) {
    PackageManager pm = context.getPackageManager();
    PackageInfo apkInfo = pm.getPackageArchiveInfo(archiveFilePath, PackageManager.GET_META_DATA);
    return apkInfo;
}

From source file:Main.java

public static int getMetaInteger(Context context, String key) throws Exception {
    ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(),
            PackageManager.GET_META_DATA);
    return Integer.parseInt(applicationInfo.metaData.get(key).toString());
}

From source file:Main.java

public static String getMeta(Activity context, String key) throws PackageManager.NameNotFoundException {
    ActivityInfo info = context.getPackageManager().getActivityInfo(context.getComponentName(),
            PackageManager.GET_META_DATA);
    String value = info.metaData.getString(key);
    return value;
}

From source file:Main.java

public static String getMetaData(Context context, String key) {
    try {/*from  ww  w  .j  a  v  a 2s  .  c  o m*/
        ApplicationInfo info = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA);
        String values = info.metaData.getString(key);
        return values;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static PackageInfo loadPackageInfo(PackageManager mPm, String packageName) {
    try {/*from w w  w. ja v  a 2  s  .c  o  m*/
        return mPm.getPackageInfo(packageName, PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS);
    } catch (NameNotFoundException e) {
        return null;
    }
}