资源简介
获取apk文件的AndroidManifest文件内容
File apkFile = new File(apkPath);
file = new ZipFile(apkFile, 1);
ZipEntry entry = file.getEntry("AndroidManifest.xml");
AXmlResourceParser parser = new AXmlResourceParser();
parser.open(file.getInputStream(entry));
代码片段和文件信息
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.commons.codec.binary.base64;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import android.content.res.AxmlResourceParser;
import com.huawei.bme.commons.util.debug.DebugLog;
import com.huawei.bme.commons.util.debug.LogFactory;
import com.huawei.igop.common.constants.PropertyKey;
import com.huawei.igop.common.plist.NSobject;
import com.huawei.igop.common.plist.PropertyListParser;
import com.huawei.igop.partner.bean.ThreeNetsContent;
import com.huawei.igop2.common.utils.RSAUtils;
public class AxmlPrinter2 {
@SuppressWarnings(“unused“)
private static final String DEFAULT_xml = “AndroidManifest.xml“;
private static final float[] RADIX_MULTS = { 0.0039063F 3.051758E-005F
1.192093E-007F 4.656613E-010F };
private static final String[] DIMENSION_UNITS = { “px“ “dip“ “sp“ “pt“
“in“ “mm“ ““ ““ };
private static final String[] FRACTION_UNITS = { “%“ “%p“ ““ ““ ““ ““
““ ““ };
public static String getManifestxmlFromAPK(String apkPath) {
ZipFile file = null;
StringBuilder xmlSb = new StringBuilder(100);
try {
int type;
File apkFile = new File(apkPath);
file = new ZipFile(apkFile 1);
ZipEntry entry = file.getEntry(“AndroidManifest.xml“);
AxmlResourceParser parser = new AxmlResourceParser();
parser.open(file.getInputStream(entry));
StringBuilder sb = new StringBuilder(10);
@SuppressWarnings(“unused“)
String indentStep = “\t“;
while ((type = parser.next()) != 1) {
switch (type) {
case 0:
log(xmlSb “l version=\“1.0\“ encoding=\“utf-8\“?>“
new object[0]);
break;
case 2:
log(false
xmlSb
“%s<%s%s“
new object[] { sb
getNamespacePrefix(parser.getPrefix())
parser.getName() });
sb.append(“\t“);
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\““
new object[] {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-12-15 11:42 Axm
文件 6148 2017-12-15 11:41 Axm
目录 0 2017-12-15 11:42 __MACOSX\
目录 0 2017-12-15 11:42 __MACOSX\Axm
文件 120 2017-12-15 11:41 __MACOSX\Axm
文件 14160 2017-12-15 11:42 Axm
文件 494 2017-12-15 11:42 __MACOSX\Axm
文件 24552 2013-10-28 09:15 Axm
文件 175 2013-10-28 09:15 __MACOSX\Axm
评论
共有 条评论