How to open the Google Play Store directly from my Android application

0 votes

In order to open the Google Play store, I have used the given code shown below:-

Intent i = new Intent(android.content.Intent.ACTION_VIEW); i.setData(Uri.parse("https://play.google.com/store/apps/details?id=my packagename "));
startActivity(i);.

However, this shows a CAV (Complete Action View) following which to select the option of the browser or play store. My objective is to open the Play Store directly without any interference. 

Feb 8 in Others by Soham
• 9,670 points
76 views

1 answer to this question.

0 votes

By using developer.andriod.com, one can solve this problem by using the market:// prefix.

For Java Users:-

final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object try {
      startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); 
} catch (android.content.ActivityNotFoundException anfe) { 
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); 
}

For Kotlin Users

try { 
      startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName"))) 
} catch (e: ActivityNotFoundException) { 
  startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$packageName"))) 
}


In using a catch/try block, the objective is for an Exception to be thrown if the Google Play Store is not installed on a target device. 

Please NOTE: That any application can register and is capable of handling the

market://details?id=<appId> Uri, 

answered Feb 8 by Rahul
• 9,680 points

Related Questions In Others

0 votes
1 answer

How to prepare an APK for the Amazon Android App Store

you should use zipalign during every build, ...READ MORE

answered Jun 1 in Others by nisha
• 2,190 points
88 views
0 votes
1 answer

open link of google play store in mobile version android

You can use Android Intents library for opening your ...READ MORE

answered Jun 9 in Others by nisha
• 2,190 points
259 views
0 votes
1 answer

How can I open a URL in Android's web browser from my application?

ry this: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri ...READ MORE

answered Jun 14 in Others by polo
• 1,480 points
904 views
0 votes
2 answers

How to get the URL of the current tab in Google Chrome?

Its so simple.... If you want to ...READ MORE

answered Aug 12, 2020 in Others by Steve
• 200 points
1,273 views
0 votes
1 answer

How to open the Google Play Store directly from my Android application?

To open Google Play AND ONLY Google ...READ MORE

answered Jun 6 in Others by nisha
• 2,190 points
193 views
0 votes
1 answer
0 votes
0 answers

How to open the Google Play Store directly from my Android application?

I have open the Google Play store ...READ MORE

5 days ago in Android by Ashwini
• 2,760 points
10 views
0 votes
1 answer

A/B Testing for builds in Google Play

there is a staged roll out feature ...READ MORE

answered Feb 18 in Others by narikkadan
• 37,660 points
92 views
0 votes
1 answer

How to create a Custom Dialog box in android?

Here I have created a simple Dialog, ...READ MORE

answered Feb 18 in Others by Rahul
• 9,680 points
168 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP