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
9 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
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
607 views
0 votes
0 answers

How to handle large http response data from observer in Angular application to avoid browser crash?

Suppose we have a angular application which ...READ MORE

Apr 19, 2019 in Others by Hemant Gajbe
1,457 views
0 votes
2 answers
0 votes
1 answer

How to open .xlsx files in MS Excel from VS Code?

Hello, to open xlxs files, or files ...READ MORE

answered Feb 17 in Others by Edureka
• 8,820 points
19 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
• 7,860 points
14 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
• 15,810 points
14 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
• 15,810 points
36 views
0 votes
1 answer

Running docker on Android

According to the documentation, the Android kernel is ...READ MORE

answered Aug 1, 2018 in Docker by Kalgi
• 52,350 points
2,939 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
24 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