Following the intent format in https://developer.chrome.com/docs/multidevice/android/intents/
intent:
HOST/URI-path
#Intent;
package=\[string\];
action=\[string\];
category=\[string\];
component=\[string\];
scheme=\[string\];
end;
We are sending HOST/URI-path: com.example/somePath?someVariableA=1
e.g. intent://com.example/somePath?someVariableA=1#Intent;package=com.example;scheme=app;end;
The android app receives data = com.example/somePath however we are missing someVariableA=1.
How can we get someVariableA=1?
When a deeplink is opened in an Android app, the parameters can be retrieved from the intent data URI.
Below is a way how you can achieve this in your Activity:
In the code snippet above, we're getting the
Intent
that started theActivity
and then extracting the dataUri
. TheUri
class has methods to parse the different parts of the URI, including the path segments and query parameters.The
getQueryParameter(String key)
method can be used to retrieve the value of "someVariableA=1" by callingdata.getQueryParameter("someVariableA")
.Remember, this code should be placed in the Activity that is started by the intent from the deeplink. In case the Activity might be started from elsewhere, you should add null checks as necessary to prevent
NullPointerException
s.