通过包名进行判断,代码如下:
/*
* check the app is installed
*/
private boolean isAppInstalled(Context context,String packagename)
{
PackageInfo packageInfo;
try {
packageInfo = context.getPackageManager().getPackageInfo(packagename, 0);
}catch (NameNotFoundException e) {
packageInfo = null;
e.printStackTrace();
}
if(packageInfo ==null){
//System.out.println("没有安装");
return false;
}else{
//System.out.println("已经安装");
return true;
}
}