[英]How to read a AndroidManifest.xml (in binary) file?
I am trying to read the content of the AndroiadManifest.xml file which seems to be in "DBase 3 data file" binary format.我正在尝试读取似乎是“DBase 3 数据文件”二进制格式的 AndroiadManifest.xml 文件的内容。
Is there any code example in Java on how to read this binary file? Java 中是否有关于如何读取此二进制文件的代码示例? I don't need write, just read the text content.我不需要写,只需阅读文本内容。
Step 1: First you need to extract.apk file using apktool第 1 步:首先您需要使用 apktool 提取.apk 文件
Step 2: Now we want to read the androidmanifest.xml file using Java DOM XML parser ex.第 2 步:现在我们要使用 Java DOM XML 解析器读取 androidmanifest.xml 文件。 want to read "uses-permission" tag form a androidmanifest.xml想从 androidmanifest.xml 中读取“uses-permission”标签
public class parse_xml
{
public static void main(String argv[])
{
try {
File fXmlFile= new File("C:\\apkfolder\\AndroidManifest.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
System.out.println("Root element :"+ doc.getDocumentElement().getNodeName());
NodeList nList= doc.getElementsByTagName("uses-permission");
System.out.println("----------------------------");
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
//System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
System.out.println(eElement.getAttribute("android:name"));
}
}
System.out.println("total no. of permissions"+ nList.getLength());
} catch (Exception e) {
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.