(1)从AndroidManifest.xml配置文件中获取meta数据 // 从Manifest.xml配置文件中获取数据 public static String getMetaValue(Context context, String metaKey) { Bundle metaData = null; String metaValue = 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) { metaValue = metaData.getString(metaKey); } } catch (NameNotFoundException e) { } return metaValue;// xxx } <meta-data android:name="api_key" android:value="xxx" /> 复制代码