User Tools

Site Tools


call_android_app_from_web_browser

Call Android App from Web Browser

Chrome supports the protocol intent. This is a not well documented protocol which can be used in Google Chrome on an Android device to open an app which has an “exported” activity.

The link in the web site needs to conform to the Android protocol syntax for intents.

<a href="intent://app.custom.device.local/customer/102#Intent;package=my.android.app.package;scheme=myscheme;end;">Link</a>

Android App

The app needs to have an activity available to the outside via an intent filter.

<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <data android:scheme="myscheme" android:host="app.custom.device.local" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>

Note: An activity can have multiple intent-filter sections. Put the above into a separate section if the activity already has an intent-filter section.

The intent filter needs an action. An intent from the web browser always has the action android.intent.action.VIEW.

The intent used to start the activity can be retrieved with getContent(). An intent can also be represented by an URI. This can be retrieved with getIntent().getData(). The URI would look like this:

myscheme://app.custom.device.local/customer/102
call_android_app_from_web_browser.txt · Last modified: 2014/09/24 14:26 by mihael