不存在该应用就跳转应用商店,这里注意,检测应用的包名,要在应用商店下载,必须在应用商店下载的有,如果是山寨APP那就跳转到下载地址吧
}
//通过包名判断应用是否存在 public boolean checkPackage(String packageName) { if (packageName == null || "".equals(packageName)) return false; try { //手机已安装,返回true getPackageManager().getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); return true; } catch (PackageManager.NameNotFoundException e) { //手机未安装,跳转到应用商店下载,并返回false Uri uri = Uri.parse("market://details?id=" + packageName); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); LovelyToast.makeText(MainActivity.this, "手机淘宝都没有还想拿优惠券?.....", 0, LovelyToast.ERROR); return false; }