运行效果:
JAVA实现:
获取系统已安装应用列表并返回List<String>对象
//使用系统API获取安装包列表public List<String> getAppList(MainActivity act) {List<String> packages = new ArrayList<String>();try {//取包信息列表List<PackageInfo> packageInfos = act.getApplicationContext().getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES | PackageManager.GET_SERVICES);//遍历包列表for (PackageInfo info : packageInfos) {//取包名String pkg = info.packageName;//添加到列表packages.add(pkg);}} catch (Throwable t) {t.printStackTrace();;}return packages;}
C++ JNI实现: