• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AXmlResourceParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parse

import android.content.res.AXmlResourceParser; //导入依赖的package包/类
public static PackageLite parse(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));
		PackageLite packageLite=new PackageLite();
		packageLite.apkMD5=	ACDDFileUtils.getMD5(apkPath);
		packageLite.size=apkFile.length();
		packageLite.checkNativeLibs(file);
		packageLite.parse(parser);
		//System.err.println(packageLite.getBundleInfo().toString());
		file.close();
		return packageLite;
		//parser.close();
	}
	catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:bunnyblue,项目名称:ACDD,代码行数:27,代码来源:PackageLite.java


示例2: 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


示例3: getAttributeValue

import android.content.res.AXmlResourceParser; //导入依赖的package包/类
public static String getAttributeValue(AXmlResourceParser parser,int index) {
	int type=parser.getAttributeValueType(index);
	int data=parser.getAttributeValueData(index);
	if (type==TypedValue.TYPE_STRING) {
		return parser.getAttributeValue(index);
	}
	if (type==TypedValue.TYPE_ATTRIBUTE) {
		return String.format("?%s%08X",getPackage(data),data);
	}
	if (type==TypedValue.TYPE_REFERENCE) {
		return String.format("@%s%08X",getPackage(data),data);
	}
	if (type==TypedValue.TYPE_FLOAT) {
		return String.valueOf(Float.intBitsToFloat(data));
	}
	if (type==TypedValue.TYPE_INT_HEX) {
		return String.format("0x%08X",data);
	}
	if (type==TypedValue.TYPE_INT_BOOLEAN) {
		return data!=0?"true":"false";
	}
	if (type==TypedValue.TYPE_DIMENSION) {
		return Float.toString(complexToFloat(data))+
			DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
	}
	if (type==TypedValue.TYPE_FRACTION) {
		return Float.toString(complexToFloat(data))+
			FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
	}
	if (type>=TypedValue.TYPE_FIRST_COLOR_INT && type<=TypedValue.TYPE_LAST_COLOR_INT) {
		return String.format("#%08X",data);
	}
	if (type>=TypedValue.TYPE_FIRST_INT && type<=TypedValue.TYPE_LAST_INT) {
		return String.valueOf(data);
	}
	return String.format("<0x%X, type 0x%02X>",data,type);
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:38,代码来源:AXMLPrinter.java


示例4: getAttributeValue

import android.content.res.AXmlResourceParser; //导入依赖的package包/类
private static String getAttributeValue(AXmlResourceParser parser,int index) {
	int type=parser.getAttributeValueType(index);
	int data=parser.getAttributeValueData(index);
	if (type==TypedValue.TYPE_STRING) {
		return parser.getAttributeValue(index);
	}
	if (type==TypedValue.TYPE_ATTRIBUTE) {
		return String.format("?%s%08X",getPackage(data),data);
	}
	if (type==TypedValue.TYPE_REFERENCE) {
		return String.format("@%s%08X",getPackage(data),data);
	}
	if (type==TypedValue.TYPE_FLOAT) {
		return String.valueOf(Float.intBitsToFloat(data));
	}
	if (type==TypedValue.TYPE_INT_HEX) {
		return String.format("0x%08X",data);
	}
	if (type==TypedValue.TYPE_INT_BOOLEAN) {
		return data!=0?"true":"false";
	}
	if (type==TypedValue.TYPE_DIMENSION) {
		return Float.toString(complexToFloat(data))+
			DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
	}
	if (type==TypedValue.TYPE_FRACTION) {
		return Float.toString(complexToFloat(data))+
			FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
	}
	if (type>=TypedValue.TYPE_FIRST_COLOR_INT && type<=TypedValue.TYPE_LAST_COLOR_INT) {
		return String.format("#%08X",data);
	}
	if (type>=TypedValue.TYPE_FIRST_INT && type<=TypedValue.TYPE_LAST_INT) {
		return String.valueOf(data);
	}
	return String.format("<0x%X, type 0x%02X>",data,type);
}
 
开发者ID:bunnyblue,项目名称:ACDD,代码行数:38,代码来源:AXMLPrinter.java


示例5: getAttributeValue

import android.content.res.AXmlResourceParser; //导入依赖的package包/类
private static String getAttributeValue(AXmlResourceParser parser, int index) {

		int type = parser.getAttributeValueType(index);
		int data = parser.getAttributeValueData(index);
		if (type == TypedValue.TYPE_STRING) {
			return parser.getAttributeValue(index);
		}
		if (type == TypedValue.TYPE_ATTRIBUTE) {
			return String.format("?%s%08X", getPackage(data), data);
		}
		if (type == TypedValue.TYPE_REFERENCE) {
			return String.format("@%s%08X", getPackage(data), data);
		}
		if (type == TypedValue.TYPE_FLOAT) {
			return String.valueOf(Float.intBitsToFloat(data));
		}
		if (type == TypedValue.TYPE_INT_HEX) {
			return String.format("0x%08X", data);
		}
		if (type == TypedValue.TYPE_INT_BOOLEAN) {
			return data != 0 ? "true" : "false";
		}
		if (type == TypedValue.TYPE_DIMENSION) {
			return Float.toString(complexToFloat(data)) +
				DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
		}
		if (type == TypedValue.TYPE_FRACTION) {
			return Float.toString(complexToFloat(data)) +
				FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
		}
		if (type >= TypedValue.TYPE_FIRST_COLOR_INT &&
			type <= TypedValue.TYPE_LAST_COLOR_INT) {
			return String.format("#%08X", data);
		}
		if (type >= TypedValue.TYPE_FIRST_INT &&
			type <= TypedValue.TYPE_LAST_INT) {
			return String.valueOf(data);
		}
		return String.format("<0x%X, type 0x%02X>", data, type);
	}
 
开发者ID:ylfzq,项目名称:apkanalysis,代码行数:41,代码来源:AXmlNode.java


示例6: getAttributeValue

import android.content.res.AXmlResourceParser; //导入依赖的package包/类
private static String getAttributeValue(AXmlResourceParser parser, int index) {
    int type = parser.getAttributeValueType(index);
    int data = parser.getAttributeValueData(index);
    if (type == TypedValue.TYPE_STRING) {
        return parser.getAttributeValue(index);
    }
    if (type == TypedValue.TYPE_ATTRIBUTE) {
        return String.format("?%s%08X", getPackage(data), data);
    }
    if (type == TypedValue.TYPE_REFERENCE) {
        return String.format("@%s%08X", getPackage(data), data);
    }
    if (type == TypedValue.TYPE_FLOAT) {
        return String.valueOf(Float.intBitsToFloat(data));
    }
    if (type == TypedValue.TYPE_INT_HEX) {
        return String.format("0x%08X", data);
    }
    if (type == TypedValue.TYPE_INT_BOOLEAN) {
        return data != 0 ? "true" : "false";
    }
    if (type == TypedValue.TYPE_DIMENSION) {
        return Float.toString(complexToFloat(data))
                + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
    }
    if (type == TypedValue.TYPE_FRACTION) {
        return Float.toString(complexToFloat(data))
                + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
    }
    if (type >= TypedValue.TYPE_FIRST_COLOR_INT
            && type <= TypedValue.TYPE_LAST_COLOR_INT) {
        return String.format("#%08X", data);
    }
    if (type >= TypedValue.TYPE_FIRST_INT
            && type <= TypedValue.TYPE_LAST_INT) {
        return String.valueOf(data);
    }
    return String.format("<0x%X, type 0x%02X>", data, type);
}
 
开发者ID:pengwei1024,项目名称:apkReSign,代码行数:40,代码来源:ResignerLogic.java


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SkeinDigest类代码示例发布时间:2022-05-22
下一篇:
Java TiffOutputSet类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap