I want to open my Android application when a user clicks on a link to my web page (preferably from a post on Facebook, but let it start with a simple URL).
To achieve this, I created an Activity UrlReceiver and added this code to my AndroidManifest.xml file (URLs are for testing only):
<activity android:name=".main.core.UrlReceiver" android:exported="true"> <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:host="martinfowler.com" android:pathPrefix="/" android:scheme="http"/> <data android:host="www.martinfowler.com" android:pathPrefix="/" android:scheme="http"/> <data android:host="test" android:scheme="myapp"/> </intent-filter> </activity>
And it works on Firefox for Android , when I log in to myapp://test/ , it automatically opens my application, when I log in to martinfowler.com , there is an Android head next to the URL that leads to my app on the tap. And that is wonderful.
But Google Chrome does not work. When I enter myapp://test/ , it starts a Google search, and when I enter martinfowler.com , it just opens a web page.
I started digging into this on the Internet and found this document: https://developer.chrome.com/multidevice/android/intents explaining that custom schemes will no longer work in Chrome, so I tried using these URLs (according with document):
intent://test/#Intent;scheme=myapp;package=com.my.app;end intent://#Intent;scheme=myapp;package=com.my.app;end intent://test/
But they also start a Google search. What to do to open an application from a URL in Google Chrome?
I tested this on both KitKat and Lolipop.
source share