在特定的情况下,我们需要通过应用程序的包名直接打开GooglePlay的详情页面,代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
public static void openGoogleMarket(Context context, String packageName) { final String appPackageName = packageName; try { Intent intent = context.getPackageManager() .getLaunchIntentForPackage("com.android.vending"); // package name and activity ComponentName comp = new ComponentName("com.android.vending", "com.google.android.finsky.activities.LaunchUrlHandlerActivity"); intent.setComponent(comp); intent.setData(Uri.parse("market://details?id=" + appPackageName)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } catch (android.content.ActivityNotFoundException anfe) { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="+ appPackageName))); } } |