I have open the google play store using the follwing code
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);.
But it shows me a Complete Action View as to select the option (browser/play store). I need to open the application in playstore directly.
You can do this using the
market://
prefix.We use a
try/catch
block here because anException
will be thrown if the Play Store is not installed on the target device.NOTE: any app can register as capable of handling the
market://details?id=<appId>
Uri, if you want to specifically target Google Play check the Berťák answerVery late in the party Official docs are here. And code described is
As you configure this intent, pass
"com.android.vending"
intoIntent.setPackage()
so that users see your app's details in the Google Play Store app instead of a chooser. for KOTLINIf you have published an instant app using Google Play Instant, you can launch the app as follows:
For KOTLIN
While Eric's answer is correct and Berťák's code also works. I think this combines both more elegantly.
By using
setPackage
, you force the device to use the Play Store. If there is no Play Store installed, theException
will be caught.All of the above answers open Google Play in a new view of the same app, if you actually want to open Google Play (or any other app) independently:
The important part is that actually opens google play or any other app independently.
Most of what I have seen uses the approach of the other answers and it was not what I needed hopefully this helps somebody.
Regards.
Many answers here suggest to use
Uri.parse("market://details?id=" + appPackageName))
to open Google Play, but I think it is insufficient in fact:Some third-party applications can use its own intent-filters with
"market://"
scheme defined, thus they can process supplied Uri instead of Google Play (I experienced this situation with e.g.SnapPea application). The question is "How to open the Google Play Store?", so I assume, that you do not want to open any other application. Please also note, that e.g. app rating is only relevant in GP Store app etc...To open Google Play AND ONLY Google Play I use this method:
The point is that when more applications beside Google Play can open our intent, app-chooser dialog is skipped and GP app is started directly.
UPDATE: Sometimes it seems that it opens GP app only, without opening the app's profile. As TrevorWiley suggested in his comment,
Intent.FLAG_ACTIVITY_CLEAR_TOP
could fix the problem. (I didn't test it myself yet...)See this answer for understanding what
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
does.If you want to open Google Play store from your app then use this command directy:
market://details?gotohome=com.yourAppName
, it will open your app's Google Play store pages.Show all apps by a specific publisher
Search for apps that using the Query on its title or description
Reference: https://tricklio.com/market-details-gotohome-1/