I am try to open my app on url click and get value from it, url looks like : path.com/item?key=value
in manifest:
<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:host="path.com"
android:pathPrefix="/item"
android:scheme="http" />
</intent-filter>
but
Uri data = getIntent().getData();
data.getPathSegments();
Log.d("TAG", "param is:" + params.get(0);
returns: param is:item /item . how to get key=value or full url
This is how I did recently in my app
Use following intent filter
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="<SCHEME_NAME>" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
In your URL use following
for Chrome
window.location = "intent://item?key=value#Intent;scheme=<SCHEME_NAME>;package=<APP_PACKAGE>;";`
other bowsers
window.location = "<SCHEME_NAME>://item?key=value";
In the Activity class use following
String uriPath = getIntent().getDataString();
uriPath will have string "item?key=value" which you can parse based on patterns.
You can Modify the "item?key=value" in your JS to send only value if required. Do experiment on this.
Follow the link for more https://developer.android.com/training/app-indexing/deep-linking.html
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