Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
70
rated 0 times [  75] [ 5]  / answers: 1 / hits: 21384  / 12 Years ago, wed, april 18, 2012, 12:00:00

I want my website to redirect to a specific app in the Google Play Market if it is opened on an android device. I followed the instructions on http://developer.android.com/guide/publishing/publishing.html:



Display the details screen for a specific application: http://play.google.com/store/apps/details?id=<package_name>.


Works great with a link the user is actively clicking on:



<a href=http://play.google.com/store/apps/details?id=<package_name>>Download app</a>


But if I am detecting the device with javascript and trying to redirect the browser automatically changes the http://... to https://... and the user is redirected to the Google Play website instead of the Google Play app on the phone.



if(navigator.userAgent.toLowerCase().indexOf(android) > -1) {
if(confirm(Download app?)) {
window.location.href= http://play.google.com/store/apps/details?id=<package_name>;
}
}


Is there any way to change this behavior, my test device is a Samsung Galaxy with android 2.3.3?


More From » android

 Answers
7

This seems to work. The redirect opens the Google Play app while using the default browser, but translates the link to https:// play.google... when using chrome



if(navigator.userAgent.toLowerCase().indexOf(android) > -1) {
if(confirm(Download app?)) {
window.location.href= market://details?id=<packagename>;
}
}

[#86172] Tuesday, April 17, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
judydestiniem

Total Points: 215
Total Questions: 109
Total Answers: 86

Location: Indonesia
Member since Wed, Jul 7, 2021
3 Years ago
;