当前位置: 首页>>代码示例>>Java>>正文


Java AXmlResourceParser.getAttributeCount方法代码示例

本文整理汇总了Java中android.content.res.AXmlResourceParser.getAttributeCount方法的典型用法代码示例。如果您正苦于以下问题:Java AXmlResourceParser.getAttributeCount方法的具体用法?Java AXmlResourceParser.getAttributeCount怎么用?Java AXmlResourceParser.getAttributeCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.res.AXmlResourceParser的用法示例。


在下文中一共展示了AXmlResourceParser.getAttributeCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPackageName

import android.content.res.AXmlResourceParser; //导入方法依赖的package包/类
public static String getPackageName(String apkname) throws Exception {
	ZipInputStream inStream = new ZipInputStream(new FileInputStream(apkname));
       ZipEntry entry;
       while (((entry = inStream.getNextEntry()) != null)) {
       	if (entry.getName().equals("AndroidManifest.xml")) {
   			AXmlResourceParser parser=new AXmlResourceParser();
   			parser.open(inStream);
   			while (true) {
   				int type=parser.next();
   				if (type==XmlPullParser.START_TAG) {
   					for (int i=0;i!=parser.getAttributeCount();++i) {
   						if (parser.getAttributeName(i).equals("package"))
   							return parser.getAttributeValue(i);
   					}
   					break;
   				}
   			}
   			break;
       	}
       }
       return "";
}
 
开发者ID:Androxyde,项目名称:Flashtool,代码行数:23,代码来源:APKUtility.java

示例2: getAttributeValue

import android.content.res.AXmlResourceParser; //导入方法依赖的package包/类
private String getAttributeValue(AXmlResourceParser parser, String attributeName) {
	for (int i = 0; i < parser.getAttributeCount(); i++)
		if (parser.getAttributeName(i).equals(attributeName))
			return AXMLPrinter.getAttributeValue(parser, i);
	return "";
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:7,代码来源:ProcessManifest.java

示例3: getManifestXMLFromAPK

import android.content.res.AXmlResourceParser; //导入方法依赖的package包/类
public static String getManifestXMLFromAPK(String apkPath) {
		ZipFile file = null;
		StringBuilder xmlSb = new StringBuilder(100);
		try {
			File apkFile = new File(apkPath);
			file = new ZipFile(apkFile, ZipFile.OPEN_READ);
			ZipEntry entry = file.getEntry(DEFAULT_XML);
			
			AXmlResourceParser parser=new AXmlResourceParser();
			parser.open(file.getInputStream(entry));
			
			StringBuilder sb=new StringBuilder(10);
			final String indentStep="	";
			
			int type;
			while ((type=parser.next()) != XmlPullParser.END_DOCUMENT) {
				switch (type) {
					case XmlPullParser.START_DOCUMENT:
					{
						log(xmlSb,"<?xml version=\"1.0\" encoding=\"utf-8\"?>");
						break;
					}
					case XmlPullParser.START_TAG:
					{
						log(false,xmlSb,"%s<%s%s",sb,
							getNamespacePrefix(parser.getPrefix()),parser.getName());
						sb.append(indentStep);
						
						int namespaceCountBefore=parser.getNamespaceCount(parser.getDepth()-1);
						int namespaceCount=parser.getNamespaceCount(parser.getDepth());
						
						for (int i=namespaceCountBefore;i!=namespaceCount;++i) {
							log(xmlSb,"%sxmlns:%s=\"%s\"",
								i==namespaceCountBefore?"  ":sb,
								parser.getNamespacePrefix(i),
								parser.getNamespaceUri(i));
						}
						
						for (int i=0,size=parser.getAttributeCount();i!=size;++i) {
							log(false,xmlSb, "%s%s%s=\"%s\""," ",
								getNamespacePrefix(parser.getAttributePrefix(i)),
								parser.getAttributeName(i),
								getAttributeValue(parser,i));
						}
//						log("%s>",sb);
						log(xmlSb,">");
						break;
					}
					case XmlPullParser.END_TAG:
					{
						sb.setLength(sb.length()-indentStep.length());
						log(xmlSb,"%s</%s%s>",sb,
							getNamespacePrefix(parser.getPrefix()),
							parser.getName());
						break;
					}
					case XmlPullParser.TEXT:
					{
						log(xmlSb,"%s%s",sb,parser.getText());
						break;
					}
				}
			}
			parser.close();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		return xmlSb.toString();
	}
 
开发者ID:bunnyblue,项目名称:ACDD,代码行数:71,代码来源:AXMLPrinter.java

示例4: getManifestXMLFromAPK

import android.content.res.AXmlResourceParser; //导入方法依赖的package包/类
public static String getManifestXMLFromAPK(String apkPath) {
		ZipFile file = null;
		StringBuilder xmlSb = new StringBuilder(100);
		try {
			File apkFile = new File(apkPath);
			file = new ZipFile(apkFile, ZipFile.OPEN_READ);
			ZipEntry entry = file.getEntry(DEFAULT_XML);
			
			AXmlResourceParser parser=new AXmlResourceParser();
			parser.open(file.getInputStream(entry));
			
			StringBuilder sb=new StringBuilder(10);
			final String indentStep="	";
			
			int type;
			while ((type=parser.next()) != XmlPullParser.END_DOCUMENT) {
				switch (type) {
					case XmlPullParser.START_DOCUMENT:
					{
						log(xmlSb,"<?xml version=\"1.0\" encoding=\"utf-8\"?>");
						break;
					}
					case XmlPullParser.START_TAG:
					{
						log(false,xmlSb,"%s<%s%s",sb,
							getNamespacePrefix(parser.getPrefix()),parser.getName());
						sb.append(indentStep);
						
						int namespaceCountBefore=parser.getNamespaceCount(parser.getDepth()-1);
						int namespaceCount=parser.getNamespaceCount(parser.getDepth());
						
						for (int i=namespaceCountBefore;i!=namespaceCount;++i) {
							log(xmlSb,"%sxmlns:%s=\"%s\"",
								i==namespaceCountBefore?"  ":sb,
								parser.getNamespacePrefix(i),
								parser.getNamespaceUri(i));
						}
						
						for (int i=0,size=parser.getAttributeCount();i!=size;++i) {
							log(false,xmlSb, "%s%s%s=\"%s\""," ",
								getNamespacePrefix(parser.getAttributePrefix(i)),
								parser.getAttributeName(i),
								getAttributeValue(parser,i));
						}
//						log("%s>",sb);
						log(xmlSb,">");
						break;
					}
					case XmlPullParser.END_TAG:
					{
						sb.setLength(sb.length()-indentStep.length());
						log(xmlSb,"%s</%s%s>",sb,
							getNamespacePrefix(parser.getPrefix()),
							parser.getName());
						break;
					}
					case XmlPullParser.TEXT:
					{
						log(xmlSb,"%s%s",sb,parser.getText());
						break;
					}
				}
			}
			parser.close();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
//		System.out.println(xmlSb.toString());
		return xmlSb.toString();
	}
 
开发者ID:bihe0832,项目名称:Android-GetAPKInfo,代码行数:72,代码来源:AXMLPrinter.java

示例5: createNodeTree

import android.content.res.AXmlResourceParser; //导入方法依赖的package包/类
public static AXmlNode createNodeTree(InputStream in) {

		AXmlNode root = new AXmlNode("root", 0);
		try {
			Stack<AXmlNode> stack = new Stack<AXmlNode>();
			stack.push(root);

			AXmlResourceParser parser = new AXmlResourceParser();
			parser.open(in);
			while (true) {
				int type = parser.next();
				if (type == XmlPullParser.END_DOCUMENT)
					break;

				switch (type) {
				case XmlPullParser.START_TAG: {
					AXmlNode parent = stack.peek();
					AXmlNode node =
						new AXmlNode(parser.getName(), parser.getDepth());
					int count = parser.getAttributeCount();
					for (int i = 0; i < count; ++i) {
						node.mAttributes.put(
							parser.getAttributeName(i),
							getAttributeValue(parser, i));
					}
					parent.mChildNodes.add(node);
					stack.push(node);
					break;
				}
				case XmlPullParser.END_TAG: {
					stack.pop();
					break;
				}
				}
			}
		} catch (Exception e) {
			root = null;
			e.printStackTrace();
		}
		return root;
	}
 
开发者ID:ylfzq,项目名称:apkanalysis,代码行数:42,代码来源:AXmlNode.java

示例6: AXMLToXML

import android.content.res.AXmlResourceParser; //导入方法依赖的package包/类
public static String AXMLToXML(byte[] axml) throws Exception {
    AXmlResourceParser parser = new AXmlResourceParser();
    ByteArrayInputStream bais = new ByteArrayInputStream(axml);
    parser.open(bais);
    StringBuilder indent = new StringBuilder(10);
    StringBuilder output = new StringBuilder(axml.length * 2);
    final String indentStep = "   ";

    while (true) {
        int type = parser.next();
        if (type == XmlPullParser.END_DOCUMENT) {
            break;
        }
        switch (type) {
            case XmlPullParser.START_DOCUMENT: {
                output.append(String
                        .format("<?xml version=\"1.0\" encoding=\"utf-8\"?>"));
                output.append("\n");
                break;
            }
            case XmlPullParser.START_TAG: {
                output.append(String.format("%s<%s%s", indent,
                        getNamespacePrefix(parser.getPrefix()),
                        parser.getName()));
                output.append("\n");
                indent.append(indentStep);

                int namespaceCountBefore = parser.getNamespaceCount(parser
                        .getDepth() - 1);
                int namespaceCount = parser
                        .getNamespaceCount(parser.getDepth());
                for (int i = namespaceCountBefore; i != namespaceCount; ++i) {
                    output.append(String.format("%sxmlns:%s=\"%s\"", indent,
                            parser.getNamespacePrefix(i),
                            parser.getNamespaceUri(i)));
                    output.append("\n");
                }

                for (int i = 0; i != parser.getAttributeCount(); ++i) {
                    output.append(String.format("%s%s%s=\"%s\"", indent,
                            getNamespacePrefix(parser.getAttributePrefix(i)),
                            parser.getAttributeName(i),
                            getAttributeValue(parser, i)));
                    output.append("\n");
                }
                output.append(String.format("%s>", indent));
                output.append("\n");
                break;
            }
            case XmlPullParser.END_TAG: {
                indent.setLength(indent.length() - indentStep.length());
                output.append(String.format("%s</%s%s>", indent,
                        getNamespacePrefix(parser.getPrefix()),
                        parser.getName()));
                output.append("\n");
                break;
            }
            case XmlPullParser.TEXT: {
                output.append(String.format("%s%s", indent, parser.getText()));
                output.append("\n");
                break;
            }
        }
    }
    return output.toString();
}
 
开发者ID:pengwei1024,项目名称:apkReSign,代码行数:67,代码来源:ResignerLogic.java

示例7: main

import android.content.res.AXmlResourceParser; //导入方法依赖的package包/类
public static void main(String[] arguments) {
	if (arguments.length<1) {
		log("Usage: AXMLPrinter <binary xml file>");
		return;
	}
	try {
		AXmlResourceParser parser=new AXmlResourceParser();
		parser.open(new FileInputStream(arguments[0]));
		StringBuilder indent=new StringBuilder(10);
		final String indentStep="	";
		while (true) {
			int type=parser.next();
			if (type==XmlPullParser.END_DOCUMENT) {
				break;
			}
			switch (type) {
				case XmlPullParser.START_DOCUMENT:
				{
					log("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
					break;
				}
				case XmlPullParser.START_TAG:
				{
					log("%s<%s%s",indent,
						getNamespacePrefix(parser.getPrefix()),parser.getName());
					indent.append(indentStep);
					
					int namespaceCountBefore=parser.getNamespaceCount(parser.getDepth()-1);
					int namespaceCount=parser.getNamespaceCount(parser.getDepth());
					for (int i=namespaceCountBefore;i!=namespaceCount;++i) {
						log("%sxmlns:%s=\"%s\"",
							indent,
							parser.getNamespacePrefix(i),
							parser.getNamespaceUri(i));
					}
					
					for (int i=0;i!=parser.getAttributeCount();++i) {
						log("%s%s%s=\"%s\"",indent,
							getNamespacePrefix(parser.getAttributePrefix(i)),
							parser.getAttributeName(i),
							getAttributeValue(parser,i));
					}
					log("%s>",indent);
					break;
				}
				case XmlPullParser.END_TAG:
				{
					indent.setLength(indent.length()-indentStep.length());
					log("%s</%s%s>",indent,
						getNamespacePrefix(parser.getPrefix()),
						parser.getName());
					break;
				}
				case XmlPullParser.TEXT:
				{
					log("%s%s",indent,parser.getText());
					break;
				}
			}
		}
	}
	catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:oprisnik,项目名称:semdroid,代码行数:66,代码来源:AXMLPrinter.java


注:本文中的android.content.res.AXmlResourceParser.getAttributeCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。