コード例 #1
0
 @SuppressWarnings("unused")
 private void getUsesPer(Element root, ApkName apkInfo) {
   apkInfo.setVersionCode(root.getAttributeValue("versionCode", NS));
   apkInfo.setVersionName(root.getAttributeValue("versionName", NS));
   Element elemUseSdk = root.getChild("uses-sdk"); // 子节点-->uses-sdk
   apkInfo.setMinSdkVersion(elemUseSdk.getAttributeValue("minSdkVersion", NS));
   List<?> listPermission = root.getChildren("uses-permission"); // 子节点是个集合
   List<String> permissions = new ArrayList<String>();
   for (Object object : listPermission) {
     String permission = ((Element) object).getAttributeValue("name", NS);
     permissions.add(permission);
   }
   apkInfo.setUses_permission(permissions);
 }
コード例 #2
0
 public ApkName getApkInfo(String apkPath) {
   ApkName apkInfo = new ApkName();
   SAXBuilder builder = new SAXBuilder();
   Document document = null;
   try {
     document = builder.build(getXmlInputStream(apkPath));
   } catch (Exception e) {
     e.printStackTrace();
     // return null;
   }
   Element root = document.getRootElement(); // 跟节点-->manifest
   apkInfo.setApkName(root.getAttributeValue("package"));
   getActivity(root, apkInfo);
   return apkInfo;
 }
コード例 #3
0
 private void getActivity(Element root, ApkName apkInfo) {
   Element element = root.getChild("application");
   List<?> activity = element.getChildren("activity"); // 子节点-->uses-sdk
   List<String> activitys = new ArrayList<String>();
   for (Object object : activity) {
     String aty = ((Element) object).getAttributeValue("name", NS);
     activitys.add(aty);
   }
   apkInfo.setActivitys(activitys);
 }