public boolean isApkInstalled(){
//需要检测apk的包名,每个都是唯一的.
String packageName = "com.xxx.xxx";
PackageInfo packageInfo;
boolean result = false;
try{
packageInfo = this.getPackageManager().getPackageInfo(packageName, 0);
if(packageInfo == null || "".equals(packageName)){
new AlertDialog.Builder(
ConfirmationActivity.this)
.setTitle("提示").setMessage("没有安装")
.setPositiveButton("确定", null).show();
}
result = true;
return result;
}
catch(NameNotFoundException e){
packageInfo = null;
new AlertDialog.Builder(
ConfirmationActivity.this)
.setTitle("提示").setMessage("没有安装:"+e.getMessage())
.setPositiveButton("确定", null).show();
return result;
}
}