Data via Query Webview String for Activity

Asked

Viewed 78 times

0

I’m not big on android programming. What I do is based on something javascript I know, which is also not much. So I wanted your help. I have an app that runs webview on mainActivity. But I need to send an information to another page that is in another Activity. Except that this information is a variable.

So far the code is like this. On mainActivity I have this excerpt, which interprets that when I click on the link to share.html page, goes to the other Activity, in this case, Shareactivity:

if (url.startsWith("compartilhar.html")) {
Intent intent = new Intent(getApplicationContext(), CompartilhaActivity.class);
startActivity(intent);
 return true;
 }

Except I can only open the share.html page in Shareactivity so:

webView.setWebViewClient(client);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/www/compartilhar.html");

I mean, I’m telling the code the page I want to open. But I needed that information to come dynamically. Simply put, on mainActivity, I would need something like:

if (url.startsWith("compartilhar.html?id=58")) {

Remembering that this id value would come from the link via html, and would be a variable.

And in shareActivity need the reverse path, tell html which variable came by Activity.

I don’t really know if that’s possible. That’s why I need help. Thanks in advance for your attention.

  • You can use this post as a help: https://answall.com/questions/48745/comond-dataos-de-uma-activity-para-other

  • I did some tests but I couldn’t. Actually it was some mistakes...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.