Skip to content Skip to sidebar Skip to footer

Android Get Url From Browser

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: Copy

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

StringuriPath= 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

Solution 2:

If the intent was to visit a URL (i.e., intent.getAction() == Intent.ACTION_VIEW), then intent.getData() will return that URL.

Uridata= intent.getData();
Stringpath= data.getPath();

Solution 3:

To get the full Uri string, you can do toString() on the Uri. But I would advise against that. Most likely, what you want is already in a method of Uri.

If you want the full path, use getPath(). If you want the full Uri as a String, toString(). If you want a specific query parameter, getQueryParameter(String key). If you want the full query string, getQuery(). If you want the keys you got in the query parameter, getQueryParameterNames().

There's a lot more. Those are the ones that I think might be useful to you based on your question.

You can, of course, do your own parsing, but most of the time it's unnecessary and error prone.

See http://developer.android.com/reference/android/net/Uri.html

Post a Comment for "Android Get Url From Browser"