AndroidManifest.xml中的元数据[重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

有没有办法从apk获取在AndroidManifest.xml中声明的元数据?

PS:不是以编程方式。

AndroidManifest.xml中

<meta-data
  android:name="password"
  android:value="abc123" />

我曾试图使用aapt d badging / apkpath。

但我得到的只是包,versionCode,versionName,platformBuildVersionName,sdkVersion,targetSdkVersion,uses-permission和application-label。

android android-manifest metadata reverse-engineering aapt
1个回答
0
投票

从语法上来说,你可以像这样读取元数据

try {
ApplicationInfo app = getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = app.metaData;
String myApiKey = bundle.getString("password");
} catch (Exception e) {
 // handle exception
}
© www.soinside.com 2019 - 2024. All rights reserved.