APK安装程序的包名

APK安装程序的包名

 Java 获取APK安装程序的包名核心的两个类:
 ResPackage
 ApkDecoder 
package com.temobi.util;

import java.io.File;
import java.util.Set;
import brut.androlib.AndrolibException;
import brut.androlib.ApkDecoder;
import brut.androlib.res.data.ResPackage; public class APKUtil {
public static String getAPKPageName(String apkpath) {
ApkDecoder d = new ApkDecoder();
d.setApkFile(new File(apkpath));
try {
Set p = d.getResTable().listMainPackages();
for (ResPackage r : p) {// 这里set最大只会等于1
return r.getName();
}
} catch (AndrolibException e) {
e.printStackTrace();
}
return null;
} public static void main(String[] args) {
System.err.println("The APK packname is : "+APKUtil.getAPKPageName("d:/UCBrowser_V8.7.0.187_Android_pf145_(Build12101613).apk"));
}
}

  

04-20 10:38