On a web page, I have a URL that is a deep link to my Android app. It is of the form myapp://myrequest?url=someurl
This is captured via an intent filter in the app manifest. I use getIntent().getData.getQueryParameter("url")
in the onCreate()
of my activity to get the someurl
part, which is what I need for further processing. The intent filter is of the form:
<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="myapp"
android:host="myrequest" />
</intent-filter>
It works perfectly on Android devices and from Android browsers installed via APK and/or the Play store on ChromeOS devices. But it does not work from the native ChromeOS browser. When the link is clicked, a dialog box opens with the message:
Google Chrome OS can't open this page
How can this be made to work? Do I have to format the URL differently? Do I have to add and/or modify the intent filter? Or is there some entirely different method I must use for ChromeOS?
After trial and error I noticed that the native ChromeOS browser does not like to use custom schemes to open Android apps.
If you instead use http
or https
the browser should ask you if you want to open the URL using your app.
Example:
<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="https"
android:host="my.app.com" />
</intent-filter>
To test launching your app, use window.open("https://my.app.com");
in the browser console.