Detect an application is installed or not?

I have a application that registers a handler for custom URI on the Phone. I am able to launch the application by making a link to "myapp://act/launch" from my phone web pages. This works only if my application is installed on the device. What I want to do is detect if the URI Scheme is supported from the browser and then prompt my own message saying "please download the app etc..." if the handler for the URI scheme is not found.

Is there a way I can detect or find the list of URL Scheme handlers on the Phone from the Web Browser ?


From Android How-to's

If you ever need to know if a particular app is installed on the user's device, you can use the PackageManager. From a Context class (e.g. an Activity or a Service) you can call getPackageManager(). This gives you a variety of methods, one of which is getPackageInfo(). Below is a method you might use. You might call it like this:

isAppInstalled("com.simexusa.campusmaps_full");

private boolean isAppInstalled(String packageName) {
    PackageManager pm = getPackageManager();
    boolean installed = false;
    try {
       pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
       installed = true;
    } catch (PackageManager.NameNotFoundException e) {
       installed = false;
    }
    return installed;
}

  1. You need to create a web page that user lands on if the app is not installed. Say http://www.yourcompany.com/android/android_app_is_not_installed_landing_page.html

  2. The app needs to register in manifest XML file host www.yourcompany.com, schema “http” and the path param to app not install landing page in the manifest intent filter:

    <!-- These intents are used to launch the app from the web page-->
    <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="www.yourcompany.com"
            android:path="/android/android_app_is_not_installed_landing_page.html" 
      />
    </intent-filter>
    
  3. Now in the web page that invokes your app you specify full link to android_app_is_not_installed_landing_page.html followed by whatever params you want to pass to the app:

http://www.yourcompany.com/android/ android_app_is_not_installed_landing_page.html? '>Click here to launch the app if it is installed

If the app is installed it will be launched and passed entire http://www.yourcompany.com/android/android_app_is_not_installed_landing_page.html?' in intent that it needs to parse, extract the and do whatever it is supposed to do.

If the app is not installed, then the Android Web browser will open “Android app not installed” landing page http://www.yourcompany.com/android/android_app_is_not_installed_landing_page.html o . That page should message user to install the app and provide the link to install it from Android marketplace.

found this write up here: https://groups.google.com/forum/m/?fromgroups#!topic/android-developers/RGLHkGUpRoA