List of usage examples for android.content.pm PackageManager GET_META_DATA
int GET_META_DATA
To view the source code for android.content.pm PackageManager GET_META_DATA.
Click Source Link
From source file:Main.java
public static String a(Context var0) { String var1 = var0.getPackageName(); String var3; try {//w w w. ja v a 2s. co m ApplicationInfo var2 = var0.getPackageManager().getApplicationInfo(var1, PackageManager.GET_META_DATA); var3 = var2.metaData.getString("TencentMapSDK"); if (!TextUtils.isEmpty(var3)) { String var4 = "[&=]"; Pattern var5 = Pattern.compile(var4); Matcher var6 = var5.matcher(var3); var3 = var6.replaceAll(""); } } catch (PackageManager.NameNotFoundException var7) { var3 = "GRYBZ-ACPWV-UIGPO-U2SRZ-KRYB6-7VFTU"; } return var3; }
From source file:Main.java
public static String getChannel(Context context) { String channelName = null;//w w w . ja va2s. c om try { ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); channelName = appInfo.metaData.getString("UMENG_CHANNEL"); } catch (Exception e) { channelName = "noChannel"; } return channelName; }
From source file:Main.java
public static ApplicationInfo getApplicationInfo(Context context) { if (context == null) { return null; }/*from w w w .jav a 2 s . co m*/ ApplicationInfo applicationInfo = null; try { applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return applicationInfo; }
From source file:Main.java
public static String getAppName(Context context, String packageName) { try {/*from w ww.jav a 2 s .c o m*/ PackageManager pm = context.getPackageManager(); ApplicationInfo info = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); return pm.getApplicationLabel(info).toString(); } catch (Exception e) { return ""; } }
From source file:Main.java
public static String getMetaData(Context context, String key) { Bundle metaData = null;// ww w. java 2 s.c om String value = null; if (context == null || key == null) { return null; } try { ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (null != ai) { metaData = ai.metaData; } if (null != metaData) { value = metaData.getString(key); } } catch (PackageManager.NameNotFoundException e) { // Nothing to do } return value; }
From source file:Main.java
public static String getMetaValue(Context context, String metaKey) { Bundle metaData = null;//from www . j av a 2s.co m String apiKey = null; if (context == null || metaKey == null) { return null; } try { ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (null != ai) { metaData = ai.metaData; } if (null != metaData) { apiKey = metaData.getString(metaKey); } } catch (PackageManager.NameNotFoundException e) { } return apiKey; }
From source file:Main.java
public static String getMetaDataValue(Context context, String name, String defaultValue) { Object value = null;/* w ww . j av a 2s . c om*/ PackageManager packageManager = context.getPackageManager(); ApplicationInfo applicationInfo; try { applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (applicationInfo != null && applicationInfo.metaData != null) { value = applicationInfo.metaData.get(name); } } catch (PackageManager.NameNotFoundException ignored) { } return value != null ? value.toString() : defaultValue; }
From source file:Main.java
public static String getAppKey(Context context) { Bundle metaData = null;// www . j a va 2s. c om String appKey = null; try { ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (null != ai) metaData = ai.metaData; if (null != metaData) { appKey = metaData.getString(KEY_APP_KEY); if ((null == appKey) || appKey.length() != 24) { appKey = null; } } } catch (NameNotFoundException e) { } return appKey; }
From source file:Main.java
public static ApplicationInfo findMetaData(Context ctx, String key) { PackageManager pm = ctx.getPackageManager(); try {/*from w w w. j a v a 2 s.c o m*/ List<PackageInfo> pkgList = pm.getInstalledPackages(0); for (PackageInfo info : pkgList) { ApplicationInfo appInfo = pm.getApplicationInfo(info.packageName, PackageManager.GET_META_DATA); Bundle bd = appInfo.metaData; if (bd == null) continue; Object obj = bd.get(key); if (obj != null) { // System.out.println("find it , panme : "+appInfo.packageName); return appInfo; } } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String getMetaValue(Context context, String metaKey) { Bundle metaData = null;/*from w w w .j a v a 2 s. co m*/ String apiKey = null; if (context == null || metaKey == null) { return null; } try { ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (null != ai) { metaData = ai.metaData; } if (null != metaData) { apiKey = metaData.getString(metaKey); } } catch (NameNotFoundException e) { } return apiKey; }