Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open google play store with button click

Tags:

android

hello I am working on my own launcher that has a button that says "Google Play" what I want it to do is when the user clicks this button it takes them to the google play store home page NOT to a specific app page

heres my code:

  /** Called when the user clicks the play button */
    public void play(View view) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setComponent(new ComponentName("com.android.vending","what goes here??"));
        intent.putExtra("grace", "Hi");
        startActivity(intent);


    }

Thanks way in advance

Regards

Chris

like image 716
ChrisDeBrodie1335 Avatar asked Feb 23 '14 19:02

ChrisDeBrodie1335


2 Answers

Some other people have got the same problem: How to click on Android Button then go to google play apps

public void play(View view) {
  Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=com.theopen.android"));
  startActivity(intent);
}

Code idea from the answer from user "MAC".

like image 156
mhellmeier Avatar answered Sep 29 '22 08:09

mhellmeier


Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.android.vending");
startActivity(launchIntent);
like image 38
Smile2Life Avatar answered Sep 29 '22 09:09

Smile2Life