Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open link of google play store in mobile version android

I have link of my other apps in my latest app, and I open them in that way.

Uri uri = Uri.parse("url"); Intent intent = new Intent (Intent.ACTION_VIEW, uri);  startActivity(intent); 

this codes opens the browser version of google play store.

When trying to open from my phone, the phone prompts if I want to use a browser or google play and if I choose the second one it opens the mobile version of google play store.

Can you tell me how can this happen at once? I mean not ask me but directly open the mobile version of google play, the one that I see while open it directly from phone.

like image 586
ghostrider Avatar asked Jun 06 '12 21:06

ghostrider


People also ask

How do I open Play Store app from link?

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.

What is the link of Google Play store?

Any http://play.google.com?id=* link will prompt the user in this way on an Android device.

How do I open the Google Play Store?

This opens the Google Play Store. TIP: If you can't find the Play Store, you can also type "play store" in the search field displayed at the top of the All Apps screen. 2. Open the Google Play Store from its Home screen shortcut Some Android smartphones come with a shortcut to the Play Store app on the Home screen for easy access.

What is Google Play Store on Android?

On your Android device, Google's Play Store is the portal to your favorite content, so knowing how to open it can come in handy. You use it to download apps, games, and all kinds of digital content. It also handles updates for your apps. This tutorial teaches you all the ways to open the Google Play Store app on your Android smartphone or tablet:

How do I open all apps on my Android phone?

Open the Google Play Store from the All Apps screen The All Apps screen is the fail-safe way to open any app on your Android device. On the Home screen, either tap the All apps button, which is available on most Android smartphones, or swipe up to access the All Apps screen.

How do I download the Play Store on my Android phone?

On the Home screen, either tap the All apps button, which is available on most Android smartphones, or swipe up to access the All Apps screen. On the All Apps screen, find the Play Store app and tap on it.


1 Answers

You'll want to use the specified market protocol:

final String appPackageName = "com.example"; // Can also use getPackageName(), as below startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); 

Keep in mind, this will crash on any device that does not have the Market installed (the emulator, for example). Hence, I would suggest something like:

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("http://play.google.com/store/apps/details?id=" + appPackageName))); } 

While using getPackageName() from Context or subclass thereof for consistency (thanks @cprcrack!). You can find more on Market Intents here: link.

like image 114
Cat Avatar answered Oct 13 '22 21:10

Cat