Skip to content

Instantly share code, notes, and snippets.

@Anjali2019
Created June 4, 2013 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Anjali2019/5703782 to your computer and use it in GitHub Desktop.
Save Anjali2019/5703782 to your computer and use it in GitHub Desktop.
import java.io.File;
import org.w3c.dom.Document;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class checkmanifest {
static boolean wakelock;
checkmanifest()
{
wakelock=false;
}
public static void main(String args[])
{
try {
check();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
static void check() throws ParserConfigurationException
{
int a;
a=1;
wakelock=true;
try
{
File fXmlFile = new File("/home/anjali/Documents/mtp/apps/Untitled1Folder/Google Maps 6.14.3 (androidfullapps.com)/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");
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("Staff id : " + eElement.getAttribute("android:name"));
// System.out.println("First Name : " + eElement.getElementsByTagName("firstname").item(0).getTextContent());
}
}
nList = doc.getElementsByTagName("activity");
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("Staff id : " + eElement.getAttribute("android:name"));
// System.out.println("First Name : " + eElement.getElementsByTagName("firstname").item(0).getTextContent());
}
}
nList = doc.getElementsByTagName("service");
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("Staff id : " + eElement.getAttribute("android:name"));
// System.out.println("First Name : " + eElement.getElementsByTagName("firstname").item(0).getTextContent());
}
}
nList = doc.getElementsByTagName("receiver");
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("Staff id : " + eElement.getAttribute("android:name"));
// System.out.println("First Name : " + eElement.getElementsByTagName("firstname").item(0).getTextContent());
}
}
nList = doc.getElementsByTagName("provider");
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("Staff id : " + eElement.getAttribute("android:name"));
// System.out.println("First Name : " + eElement.getElementsByTagName("firstname").item(0).getTextContent());
}
}
}
catch(Exception e)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment