How to parse the AndroidManifest.xml file inside an .apk package

前端 未结 16 1371
暖寄归人
暖寄归人 2020-11-22 10:32

This file appears to be in a binary XML format. What is this format and how can it be parsed programmatically (as opposed to using the aapt dump tool in the SDK)?

16条回答
  •  旧巷少年郎
    2020-11-22 11:02

    it can be helpful

    public static int vCodeApk(String path) {
        PackageManager pm = G.context.getPackageManager();
        PackageInfo info = pm.getPackageArchiveInfo(path, 0);
        return info.versionCode;
        //        Toast.makeText(this, "VersionCode : " + info.versionCode + ", VersionName : " + info.versionName, Toast.LENGTH_LONG).show();
    }
    

    G is my Application class :

    public class G extends Application {
    

提交回复
热议问题