Problem Description
I am writing Android application and I need to add to my application some functionality, when user open standard web browser in Android and navigate to me web page (http://mywebpage.com) and there press on some button (Test Button) web page must detect if my application is already installed on the Android phone.
What I do to solve this problem
I have read many articles and ask here some questions and I understand that I can’t do something in order my web page can understand if My Application is installed on the phone or not, the one thing that I can do it write some code in the manifest file
<a href="my.special.scheme://other/parameters/here">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="my.special.scheme" />
</intent-filter>
But this is not enough for me as if application is not installed on the phone when user press on the link in my web site it give an 404 error saying that there is no such URL my.special.scheme://other/parameters/here I want to find another solution for this and here what I think.
Solution for the problem
How I can throw some exception from my web site when user press on the link <a href="my.special.scheme://other/parameters/here"> and it show 404 error. I mean can I make some AJAX or JAVA Script calls in order to determine that url refer to not valid link and redirect to another link in that case.
Solution for the problem 2
I use intent filter like this
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="commonsware.com" android:path="LaunchApp"/>
</intent-filter>
and place a link on a web page like this
<a href="commonsware.com/LaunchApp">Start App</a>.
Question
How I can redirect to the URL which I specify when the real URL does not exist or it give 404 error. Please provide me an examples as I am not strong in AJAX and JAVA Script coding
I have done something like that, based on this answer of Diane Hackborn here:
I built an Intent as to launch the desired activity and then, as described, converted the Intent to an URI and printed that to stdout. This URI (it starts with
intent:as a scheme) I used in my web-page like so:<a href="intent:/...">Start App</a>.This will start the Activity, if the Application is installed, otherwise it brings up the Play-Store App, already showing the App’s page (if found in the Play-Store, that is) for the User to download and install.