【Android】获取手机中已安装apk文件信息(PackageInfo、ResolveInfo)(应用图片、应用&nb
来源:学习笔记 责任编辑:栏目编辑 发表时间:2013-07-01 03:07 点击:次
众所周知,通过PackageManager可以获取手机端已安装的apk文件的信息,具体代码如下:
- PackageManager packageManager = this.getPackageManager();
- List<PackageInfo> packageInfoList = packageManager.getInstalledPackages(0);
- /**
- * 查询手机内非系统应用
- * @param context
- * @return
- */
- public static List<PackageInfo> getAllApps(Context context) {
- List<PackageInfo> apps = new ArrayList<PackageInfo>();
- PackageManager pManager = context.getPackageManager();
- //获取手机内所有应用
- List<PackageInfo> paklist = pManager.getInstalledPackages(0);
- for (int i = 0; i < paklist.size(); i++) {
- PackageInfo pak = (PackageInfo) paklist.get(i);
- //判断是否为非系统预装的应用程序
- if ((pak.applicationInfo.flags & pak.applicationInfo.FLAG_SYSTEM) <= 0) {
- // customs applications
- apps.add(pak);
- }
- }
- return apps;
- }
- 获取图片、应用名、包名:
- PackageManager pManager = MessageSendActivity.this.getPackageManager();
- List<PackageInfo> appList = Utils.getAllApps(MessageSendActivity.this);
- for(int i=0;i<appList.size();i++) {
- PackageInfo pinfo = appList.get(i);
- ShareItemInfo shareItem = new ShareItemInfo();
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>