Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect from browser if a specific application is installed in Android

Tags:

android

I'm looking for a way to find out if a specific application is installed from a client-side web browser. The platform is Android.

For example I write my own web site and I write my own application, now I want to when user comes to my own site from Android phone Browser. The Browser look if the application is already installed on the phone and if not suggest to install application. Can I do that ?

like image 440
Itay Kahana Avatar asked Jul 31 '11 10:07

Itay Kahana


People also ask

How can I check if an app is installed from a Web page on an android?

But you can do a trick to open the app if it's installed or open its Google Play page if it isn't. Explaining: when the user navigates to http://www.myurl.com/openmyapp, if the app is installed, an intent will be created and the Activity will be shown.

Can a website check if an app is installed?

Your website can check if your Android app is installed.

How do I track installed apps on Android?

On your Android phone, open the Google Play store app and tap the menu button (three lines). In the menu, tap My apps & games to see a list of apps currently installed on your device. Tap All to see a list of all apps you've downloaded on any device using your Google account.


2 Answers

There is a way to achieve this.

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.LAUNCHER" />         </intent-filter>     </activity>  

Explaining: when the user navigates to http://www.myurl.com/openmyapp, if the app is installed, an intent will be created and the Activity will be shown.

But what if the user doesn't have the app installed? Then you need to create a redirect page on your http://www.myurl.com/openmyapp/index.html. When the user reaches this address, your server must redirect to market://details?id=com.your.app.package.

This way, when no Intent is created after the user navigates to http://www.myurl.com/openmyapp, the webserver will call another URL. That URL, in turn, will open Google Play on the device, directly on the app's page.

Hope it helps.

like image 105
leocadiotine Avatar answered Oct 09 '22 03:10

leocadiotine


You mean from JavaScript running in the browser? I think (hope) that's impossible. I wouldn't want any random website to be able to see what apps are installed.

If you want the user to install a particular app, you can provide a Market link on your website: http://developer.android.com/guide/publishing/publishing.html#marketintent

Edit: After your clarification in the comments to my answer, a more useful answer appeared below, which rightfully has more upvotes.

like image 35
Thomas Avatar answered Oct 09 '22 02:10

Thomas