获取app 信息

可以通过appt.exe 来获取app的所有信息

public String versionName(String apkPath) {
        String versionName = "";
        InputStream inputStream = null;
        BufferedReader bufferedReader = null;
        try {
            Runtime rt = Runtime.getRuntime();
            /*String order = ReadPro.getValue("aaptPath") + " d badging \""
                    + apkPath + "\"";*/
            String order = null;
            if (os.toLowerCase().contains("windows")) {
                order = ReadPro.getValue("aaptPath") + " d badging \""+ apkPath + "\"";
            }else {
                order = ReadPro.getValue("aaptPath") + " d badging " + apkPath ;
            }
            Process proc = rt.exec(order);
            new StreamGobbler(proc.getErrorStream()).start();
            inputStream = proc.getInputStream();
            bufferedReader = new BufferedReader(new InputStreamReader(
                    inputStream, "UTF-8"));
            String line = null;
            while ((line = bufferedReader.readLine()) != null) {
                if (line.contains("versionName")) {
                    String str1 = line
                            .substring(line.indexOf("versionName") + 13);
                    String str2 = str1.substring(0, str1.indexOf("'"));
                    versionName = str2;
                    break;
                }
            }
        } catch (Throwable e) {
            e.printStackTrace();
        } finally {

            try {
                if (inputStream != null) {
                    inputStream.close();
                }
                if (bufferedReader != null) {
                    bufferedReader.close();
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
        return versionName;
    }

 

posted @ 2016-05-09 15:03  phyxis_xu  阅读(269)  评论(0编辑  收藏  举报