If you want to obtain information in the xml file in the Android package, can anyone provide some ideas. If you want to obtain information in the xml file in the Android package, can anyone provide some ideas.
Reply content:
If you want to obtain information in the xml file in the Android package, can anyone provide some ideas.
First of all, as mentioned above, the apk file is only a zip package, so you have the idea: use php to decompress the package and read the decompressed file to achieve the goal of the subject.
Search for "php to decompress". there are many examples on the Internet, such as http://jb51.net/article/25521.htm.
I hope the subject will try to solve the problem next time.
You need to install the apktool to decompile the apk file, and then use preg_match to match the required parameters from the package information. this is the method I have done before!
Reference: https://github.com/iBotPeaches/Apktool
Update:
I found the previously written code, hoping to help you:
/*** Get APK package information and application icons (exec supported) */public function apkParseInfo ($ apk) {$ aapt = '/usr/bin/aapt '; if (FALSE = is_file ($ aapt) {return FALSE;} exec ("{$ aapt} d badging {$ apk}", $ output, $ return ); // parsing error if ($ return! = 0) {return FALSE;} $ output = implode (PHP_EOL, $ output); $ apkinfo = new stdClass; // name displayed externally $ pattern = "/application: label = '(. *) '/isU "; $ results = preg_match ($ pattern, $ output, $ res); $ apkinfo-> label = $ results? $ Res [1]: ''; // internal name, which is the only $ pattern ="/package: name = '(. *) '/isU "; $ results = preg_match ($ pattern, $ output, $ res); $ apkinfo-> sys_name = $ results? $ Res [1]: ''; // Internal version name, used to check upgrade $ pattern ="/versionCode = '(. *) '/isU "; $ results = preg_match ($ pattern, $ output, $ res); $ apkinfo-> version_code = $ results? $ Res [1]: 0; // version name displayed externally $ pattern = "/versionName = '(. *) '/isU "; $ results = preg_match ($ pattern, $ output, $ res); $ apkinfo-> version = $ results? $ Res [1]: ''; // The system supports $ pattern ="/sdkVersion :'(. *) '/isU "; $ results = preg_match ($ pattern, $ output, $ res); $ apkinfo-> sdk_version = $ results? $ Res [1]: 0; // resolution supported $ densities = array ("/densities :'(. *) '/isU ","/densities: '000000 ''(. *) '/isU ","/densities: '000000 ''(. *) '/isU ","/densities: '000000 ''(. *) '/isU ","/densities: '000000' '000000 ''(. *) '/isU ","/densities: '000000' '000000 ''(. *) '/isU ","/densities: '000000' '000000' '000000 ''(. *) '/isU "); foreach ($ densities AS $ k => $ v) {if (preg_match ($ v, $ output, $ res )) {$ apkinfo-> densities [] = $ res [1] ;}} // application permission $ Pattern = "/uses-permission :'(. *) '/isU "; $ results = preg_match_all ($ pattern, $ output, $ res); $ apkinfo-> permissions = $ results? $ Res [1]: ''; // required features (hardware supported) $ pattern ="/uses-feature :'(. *) '/isU "; $ results = preg_match_all ($ pattern, $ output, $ res); $ apkinfo-> features = $ results? $ Res [1]: ''; // application icon path if (preg_match ("/icon = '(. +) '/isU ", $ output, $ res) {$ icon_draw = trim ($ res [1]); $ icon_hdpi = 'Res/drawable-hdpi /'. basename ($ icon_draw); $ temp = $ this-> _ file_save_path. basename ($ apk, '.apk '). DIRECTORY_SEPARATOR; if (@ is_dir ($ temp) === FALSE) {create_dir ($ temp);} exec ("unzip {$ apk} {$ icon_draw}-d ". $ temp); exec ("unzip {$ apk} {$ icon_hdpi}-d ". $ temp); $ apkinf O-> icon = $ icon_draw; $ icon_draw_abs = $ temp. $ icon_draw; $ icon_hdpi_abs = $ temp. $ icon_hdpi; $ apkinfo-> icon = @ is_file ($ scheme )? $ Icon_hdpi_abs: $ icon_draw_abs;} return $ apkinfo ;}
The Android apk file is actually a zip package. you can directly read the xml file.
Xml file informationIfAndroidManifest.xml
You need to use aapt to read the data and call the system command.