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
• 8,730 points
15 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
• 8,980 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,160 points
24 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,160 points
21 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,500 points
21 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
722 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,160 points
20 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
• 10,840 points
24 views
0 votes
0 answers

After 4 days app is still not indexed in Google Play search

I have published my first application (Voice ...READ MORE

Mar 4 in Digital Marketing by Kichu
• 19,040 points
21 views
0 votes
0 answers

After 4 days app is still not indexed in Google Play search

I have published my first application (Voice ...READ MORE

Mar 6 in Digital Marketing by Kichu
• 19,040 points
41 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
• 8,980 points
42 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP