3

I'm currently opening Google Play the way that is described many places: by starting a new intent pointing at the market, as described here:

open link of google play store in mobile version android

But that leaves the market open if the user doesn't hit the back button, and instead clicks on my app's icon again.

Is there an easy way to force Google Play to load in its own application, instead of as a new Activity on top of mine?

1 Answer 1

4
public void goToMarket(){
    Uri uri = Uri.parse("market://details?id=" + getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    goToMarket.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    try {
        startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, getResources().getString(R.string.errorLaunchMarket), Toast.LENGTH_LONG).show();
    }
}

As stated you could add the Intent.FLAG_ACTIVITY_NEW_TASK to your setFlags().

1
  • It turns out I needed to add one more flag to make this open in a new task. Add the Intent.FLAG_ACTIVITY_NEW_TASK to your setFlags() call, and it does exactly what I needed.
    – Sky Kelsey
    Commented Dec 15, 2012 at 2:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.