private void initFMMap() { ApplicationInfo appInfo = null; try { appInfo = this.getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } String msg = appInfo.metaData.getString("com.fengmap.mapapi.appkey"); Log.e(TAG, "before: " + msg); appInfo.metaData.putString("com.fengmap.mapapi.appkey", "b22ac5888df02143841ce28817f41942aaa"); msg = appInfo.metaData.getString("com.fengmap.mapapi.appkey"); Log.e(TAG, "after: " + msg); }
注意:
该修改方式只会针对同一个类文件,如果更换类文件再次读取mete-date时,数据将会恢复成Manifest.xml中配置的数据