Android:UrlScheme
lastmod 2018-08-17created 2016-12-141 edits
Explains how to use Android URL Schemes.
How to call an Android Activity using a URL Scheme
First, modify AndroidManifest.xml in the called (Destination) app as follows.
<activity
android:name=".BkCalculatorActivity"
android:label="@string/title_activity_calc">
<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="bk" android:host="calc"/>
</intent-filter>
</activity>
The important parts are android:scheme and android:host. Converted to a URI, the example above becomes:
Next, add code to the corresponding Activity.onCreate() of the called app so it can receive the URI data.
Uri data = getIntent().getData();
if (data != null) {
String get_op1 = data.getQueryParameter("op1");
String get_op2 = data.getQueryParameter("op2");
}
Converted to a URI, the example above becomes:
Finally, the calling side builds the Intent as follows.
Uri uri = Uri.parse("bk://calc?op1=100&op2=200");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setAction(Intent.ACTION_VIEW);
startActivity(intent);
See also
Favorite stie
References
-
Blog.daum.net_-mailss-_android_url_scheme.pdf ↩