开发者

How to parse the uploaded apk file with Java code?

I want to know how to implement java code to parse the apk file, get the android application version number and so on, such as after you uploaded android application in Android Market, it will开发者_如何学JAVA get the version number, permissions.

Anyone can give me idear? Thanks a lot.


You can refer to https://github.com/xiaxiaocao/apk-parser, which is a pure java apk-parser implementation.


PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA); 
version = pInfo.versionName.toString(); 


Though the question is quite outdated, I add my solution here for people looking for howtos.

You can use aapt dump badging abc.apk to dumpp version code, pacakge name, etc information under command line. Then you can use Java to create a process, execute the command, and get the output of the command as a String.

You know how to do the following things. Use regex to parse the output and get the data you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜