Retrieving data for a custom URL scheme in Android

Currently, in my application, I have my own URI scheme for detecting when a user clicks on a specific URI.

The code used in the Manifest file is as follows:

 <intent-filter> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="com.test/> <action android:name="android.intent.action.VIEW" /> </intent-filter> 

If a user clicks on a link that has its own user URI in the browser, it now displays options for the user to select my application.

But how to transfer this data, which is a link to my application at startup for further processing? Basically, how do I transfer data from the browser to my application?

Thanks at Advance

+8
android android-intent android-manifest
source share
1 answer

Suppose your url is: http://twitter.com/status/1234
You can get the data using the following method.

  // http://twitter.com/status/1234 Uri data = getIntent().getData(); Log.d(TAG, data.toString()); String scheme = data.getScheme(); // "http" Log.d(TAG, scheme); String host = data.getHost(); // "twitter.com" Log.d(TAG, host); String inurl = data.toString(); List<String> params = data.getPathSegments(); String first = params.get(0); // "status" String second = params.get(1); // "1234" 
+11
source share

All Articles