0

I created a blog that focus on helping smartphone users to find best and helpful applications to use on smartphones.

I created a blog post on Avast Antivirus with a link to Playstore. The link was given in bb code but when I tested the link it only opens in the browser rather than it should open the application page in Playstore of the phone. The url used was :

https://play.google.com/store/apps/details?id=com.avast.android.mobilesecurity

but I am not able to understand why this link is not redirecting the user to playstore and why this is opening in the browser only.

halfer
  • 19,824
  • 17
  • 99
  • 186
Er Vijay Gir
  • 11
  • 1
  • 1
  • Make sure to reset the `App Preferences` under `Config->Applications`. The `url` above should ask the user to choose between a browser or google play itself. – vinitius Feb 19 '15 at 19:24
  • I just tried to download the stack exchange android application from the bottom of this page. The same problem as of mine. The link redirects to the playstore on browser only not to the play store of phone to download application. – Er Vijay Gir Feb 19 '15 at 19:25
  • Check this question (http://stackoverflow.com/questions/11753000/how-to-open-the-google-play-store-directly-from-my-android-application) – sergiomse Feb 19 '15 at 19:28
  • vinitius you are right that the url should ask this but its not happening. Did u ever try to download the stack exchange application ?? the link is in the bottom of the page. It having the same problem I think. can u please tell me how to config the application that you are saying. – Er Vijay Gir Feb 19 '15 at 19:28
  • @ErVijayGir I am asked to choose between google play or my browser when I click to download the SO app. Do it like this: go to `Config`->`Application Manager` or `Appications`-> hit the menu option(depending on your device it can be in several ways)-> `Reset app defaults` and confirm. Then , try again – vinitius Feb 19 '15 at 19:33
  • can we have some html code for try and catch method? I m new to programming. I hope you understand. I m too trying Try and catch method – Er Vijay Gir Feb 19 '15 at 19:33
  • Yeah Its just a blog but I m wishing to create a link that should open the apication in playstore of the phone. and i think in the begining of code the keyworld should be "url" instead of "Uri" – Er Vijay Gir Feb 19 '15 at 19:41
  • @ErVijayGir Did you try to reset your apps preferences ? – vinitius Feb 19 '15 at 19:43
  • the doc mentions `http` instead of `https`, not sure that should make a difference, though. – njzk2 Feb 19 '15 at 19:56

3 Answers3

1

To launch the Play Store app to load the target page you need to use below URL

market://details?id=com.avast.android.mobilesecurity

instead of https://play.google.com/store/apps/details?id=com.avast.android.mobilesecurity

You can refer this page for details.

Shubhangi
  • 2,229
  • 2
  • 14
  • 14
0

You can try this:

Uri uri = Uri.parse("market://details?id=com.avast.android.mobilesecurity");
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
try {
    startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
    Toast.makeText(mContext, "Couldn't launch play store", Toast.LENGTH_LONG).show();
}
Vamsi
  • 878
  • 1
  • 8
  • 25
  • I understand that he doesn't have an android app. It's just a blog in some web page – vinitius Feb 19 '15 at 19:34
  • If not in android code, then the link **market://details?id=com.avast.android.mobilesecurity** can be used. – Vamsi Feb 19 '15 at 19:57
0

Looks like you're after help with your website, not with an Android app.

What you'll want to do is check if the user is reading your blog on their Android device or not, then show the appropriate link.

A very rough idea of what you're after (in JavaScript):

function playStoreLink(packageId) {
    if(navigator.userAgent.match(/Android/i)) {
        window.location.href = "market://details?id=" + packageId;
    }
    else {
        window.location.href = "https://play.google.com/store/apps/details?id=" + packageId;
    }
}

What a link may look like:

<a href="javascript:playStoreLink('com.avast.android.mobilesecurity')">Avast Mobile Security</a>
mkorcha
  • 171
  • 1
  • 11