获取manifest中参数信息的方法

/**获取AppKey*/
public String getMetaValue() {
Bundle metaData = null;
String apiKey = null;
try {
ApplicationInfo ai =getPackageManager().getApplicationInfo(
getPackageName(), PackageManager.GET_META_DATA);
if (null != ai) {
metaData = ai.metaData;
}
if (null != metaData) {
//api_key 字符串要跟manifest配置文件里定义key对应
apiKey = metaData.getString("api_key");
}
} catch (NameNotFoundException e) {

}
return apiKey;
}

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

<application>

<meta-data android:name="api_key" android:value="DOkP8ZRiuIdrjpdE6Ssmlhpk" />
</application>

原文地址:https://www.cnblogs.com/clarence/p/3558013.html