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, 2022 in Others by Soham
• 9,710 points
864 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, 2022 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, 2022 in Others by nisha
• 2,210 points
626 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, 2022 in Others by nisha
• 2,210 points
1,611 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, 2022 in Others by polo
• 1,480 points
4,803 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
3,580 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, 2022 in Others by nisha
• 2,210 points
1,976 views
0 votes
1 answer

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

If you want to link to your ...READ MORE

answered Nov 7, 2022 in Android by Edureka
• 12,690 points
4,332 views
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

Nov 23, 2022 in Android by Ashwini
• 5,430 points
718 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, 2022 in Others by narikkadan
• 63,600 points
594 views
0 votes
1 answer
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, 2022 in Others by Rahul
• 9,680 points
1,099 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