我自横刀向天笑,去留肝胆两昆仑。这篇文章主要讲述Android 判断app是否安装相关的知识,希望能为你提供帮助。
1.
private boolean isAppInstalled(Context context, String uri) { PackageManager pm = context.getPackageManager(); boolean installed = false; try { pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); installed = true; } catch (PackageManager.NameNotFoundException e) { installed = false; } return installed; }
2.
public boolean isAppInstalled(Context context, String packageName) { final PackageManager packageManager = context.getPackageManager(); List< PackageInfo> pinfo = packageManager.getInstalledPackages(0); List< String> pName = new ArrayList< String> (); if (pinfo != null) { for (int i = 0; i < pinfo.size(); i++) { String pn = pinfo.get(i).packageName; pName.add(pn); } } return pName.contains(packageName); }
例子:
if (isInstallApp(MainActivity.this, "com.xxx")) { System.out.println("Installed!!"); } else { System.out.println("Not installed!!"); }
【Android 判断app是否安装】
推荐阅读
- 咏南WEB APP开发框架
- Dapper扩展SQL跟踪及全局缓存通知
- 使用application作用域实现(当用户重复登录时,挤掉原来的用户)
- 趣头条系统APP开发
- NetAppsystem manager使用域用户访问
- Android 为控件添加点击涟漪效果
- 最新win7系统还原图文图文详细教程
- 安装系统 本文教你一键重装系统Ghost xp旗舰版系统工具哪个好
- ghost一键重装windows7系统图文图文详细教程