1)build.gradle->android->defaultConfig内添加如
manifestPlaceholders = [
JPUSH_APPKEY : "XXX",//值来自开发者平台取得的AppKey
JPUSH_CHANNEL: "default_developer",
design_width_in_dp:360,
design_height_in_dp:640
]
2)如Application中引入需在AndroidManifest.xml中的Application中标签引入
<meta-data android:name="JPUSH_APPKEY" android:value="${JPUSH_APPKEY}"/>
同理android四大组件需引入也是放相应标签
3)java访问数据
try {
ApplicationInfo appInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);//Application中
//ActivityInfo appInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);//Activity中
//services receiver只是改个名字类似
String JPUSH_APPKEY = appInfo.metaData.getString("JPUSH_APPKEY");
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}