怎么判断是否安装了第三方app
判断是否安装了某个app,我们是通过包名检测系统中是否安装了某个应用程序
/**
* 判断手机是否安装百度或者高德地图 只要安装一个即可
*/
private boolean ifInstallMap() {
return isPackageInstalled(this, "com.autonavi.minimap")
|| isPackageInstalled(this, "com.baidu.BaiduMap");
}
private boolean isPackageInstalled(Context c, String pn) {
PackageManager packageManager = c.getPackageManager();
try {
PackageInfo pi = packageManager.getPackageInfo(pn,PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
if (null != pi) {
return true;
}
} catch (NameNotFoundException e) {
e.printStackTrace();
return false;
}
return false;
}