Currently in my app, I have my own URI scheme to detect when user clicks on a particular URI.
Code used in Manifest
file is as below:
<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 which has my custom URI in browser, It will now popup a options for user to choose my app.
But how do I pass this data which is the link to my app when started for further processing? Basically how do I pass data from browser to my app?
In Android, a deep link is a link that takes you directly to a specific destination within an app. The Navigation component lets you create two different types of deep links: explicit and implicit.
By using Android Debug Bridge (ADB) shell commands one can test the deep link flow. It is used to verify if the link navigates to the correct section of your app. This command starts the ADB shell with the VIEW action and specifies the deep link URL to be tested.
📘 URL Schemes are an advanced configuration option used to define a non-standard link format that will only open in your app and not the device browser e.g. youruniquestring://yoursite.com/path This functionality is helpful in authentication redirect flows or for a more seamless user experience.
Suppose that 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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With