how to check app is installed or not in android using JavaScript

You cannot detect if a particular application is installed, for security and privacy reasons. But you can do a trick to open the app if it’s installed or open its Google Play page if it isn’t.

To do that, you must create an intent-filter on your app’s main activity, to open it when a given URL is called. Like this:

<activity android:name=".MainActivity >
    <intent-filter>
        <data
            android:host="www.myurl.com"
            android:pathPrefix="/openmyapp"
            android:scheme="http" >
        </data>

        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.VIEW" />
    </intent-filter>
</activity> 
var now = new Date().valueOf();
setTimeout(function () {
    if (new Date().valueOf() - now > 100) return;
    window.location = "https://itunes.apple.com/appdir";
}, 25);
window.location = "appname://";

source : stackoverflow



Leave a Reply