directly from mexico, eduardo shares some knowledge on the xamarin platform. also, he is super into artificial intelligence, so you may also see some posts about that here.

Opening the Play Store Programmatically in Xamarin Forms

Opening the Play Store Programmatically in Xamarin Forms

Recently a student of mine asked a fascinating question that I hadn’t come up with, but that seemed to be easily implementable and super useful in at least one typical scenario: send your users over to the Play Store to get the latest available update to your app.

android-applications-apps-50614.jpg

Now, the code that I will introduce in this post is not only useful for that, of course. The code will be able to open the Play Store and show any app that you want (you just have to get their package id which is super easy). I will also introduce a slightly different version of this implementation so that you can open the Play Store showing all the apps listed under a specified publisher.

Opening the Play Store

Let's dive right in. This code proved so simple thanks to some neat implementation from the Xamarin Forms package that that introduction was longer than the explanation that is coming next:

Getting the Package Id

If you want to open the Play Store showing a particular app, you will first need the package id. If it is your app the want that you want to show, you already have that over in your manifest (formatted something like com.lalorosas.MySuperSecretApp).

If, on the other hand, you want to display some other app, you can always find that package id over in your browser by navigating to the Google Play Store (play.google.com) and searching for the app you want. The url will contain that package id.

Screen Shot 2019-01-22 at 19.39.16.png

Once you have the id, all you need to do is add the following line of code to wherever you need it to be (typically the execute function to a command that you have bound to a button).

Device.OpenUri(new Uri("market://details?id=com.udemy.android"));

And yes, that is it.

Now, as I mentioned, you may want to open the Play Store for a different reason: maybe to show all the apps you (or anyone else) have listed. In that case, a similar code will be needed, only this time, instead of requesting some details for a particular id, you will perform a search and pass a query:

Device.OpenUri(new Uri("market://search?q=pub:Udemy"));

There you have it. Of course, you should keep in mind that this will only work on an Android device, so make sure you make the proper evaluations when executing this shared code.

Changing ListView Selection color with a Custom Renderer

Changing ListView Selection color with a Custom Renderer

Testing your Xamarin Forms App - iOS Simulator

Testing your Xamarin Forms App - iOS Simulator