Uri uri; if (hasAnyMarketInstalled(getContext())) { uri = Uri.parse("market://details?id=" + getPackageName()); } else { Toast.makeText(getApplicationContext(), "您没有安装应用市场", 0).show(); return; } intent.setData(uri); intent.setAction(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);
判断手机是否安装应用市场: public static boolean hasAnyMarketInstalled(Context context) { Intent intent = new Intent(); intent.setData(Uri.parse("market://details?id=android.browser")); List<ResolveInfo> list = context.getPackageManager() .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return 0 != list.size(); }