Recently, you just need to obtain the permission of the installed APK package.
As we all know, Android permission declarations are stored in androidmanifest. xml.
The format in the uses-Permission field is as follows:
<Uses-Permission Android: Name = "write_external_storage"/>
If you want to obtain the content in this tag
The following code is required:
Packagemanager PM = This. getpackagemanager (); <br/> packageinfo Info; <br/> try {<br/> info = PM. getpackageinfo (getpackagename (), packagemanager. get_permissions); <br/> string result = NULL; <br/> string [] packagepermissions = info. requestedpermissions; <br/> log. I ("name", info. packagename); <br/> If (packagepermissions! = NULL) {<br/> for (Int J = 0; j <packagepermissions. length; j ++) {<br/> log. I ("result", packagepermissions [J]); <br/>}</P> <p >}else {<br/> log. I ("name", info. packagename + ": No permissions"); <br/>}< br/>} catch (namenotfoundexception E) {<br/> // todo auto-generated Catch Block <br/> E. printstacktrace (); <br/>}
Note that the flag of the getpackageinfo function must be set to packagemanager. get_permissions.
The first parameter is to write string packagename, that is, the package name that you want to obtain permissions.
You can write the name of any installed package to obtain the permission.
This article is owned by Zeng Yang, a csdn blog blogger.
Bytes