Differences

This shows you the differences between two versions of the page.

Link to this comparison view

call_android_app_from_web_browser [2014/09/24 16:26]
call_android_app_from_web_browser [2021/04/05 11:23] (current)
Line 1: Line 1:
 +====== 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.
  
 +===== Web Link =====
 +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''.
 +
 +<sxh xml>
 +<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>
 +</sxh>
 +
 +<note>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.</note>
 +
 +<note important>The intent filter needs an action. An intent from the web browser always has the action ''android.intent.action.VIEW''.</note>
 +
 +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
 +  
 +===== Links =====
 +  * [[https://developer.chrome.com/multidevice/android/intents | Android Intents with Chrome]]
 +  * [[http://stackoverflow.com/questions/23231589/intent-anchor-syntax-description | Intent Anchor Syntax Description]]
 +
 +{{tag>android java}}