How to register some URL namespace (myapp://app.start/) for accessing your program by calling a URL in browser in Android OS?

First, to be able to start your app from link with custom scheme ‘myapp’ in browser / mail,
set intent filter as follows.

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

and to parse queries in your link myapp://someaction/?var=str&varr=string
(the code is over simplified and has no error checking.)

Intent intent = getIntent();
// check if this intent is started via custom scheme link
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
  Uri uri = intent.getData();
  // may be some test here with your custom uri
  String var = uri.getQueryParameter("var"); // "str" is set
  String varr = uri.getQueryParameter("varr"); // "string" is set
}

[edit]
if you use custom scheme to launch your app, one of the problem is that:
The WebView in another apps may not understand your custom scheme.
This could lead to show 404 page for those browser for the link with custom scheme.

Leave a Comment