Data via Query String from Webview to Activity

0

I'm not a great Android programmer. What I do is based on something javascript I know, which is not much either. So I wanted your help. I have an application that runs in webview, in mainActivity. But I need to send an information to another page that is in another activity. But this information is a variable.

For now the code is like this. In the mainActivity I have this section, which interprets that when I click the link to the page share.html, 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;
 }

I can only open the share.html page in ShareActivity like this:

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

That is, I am informing the code of the page that I want to open. But I needed this information to come dynamically. Simply put, in 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 the exact ShareActivity of the inverse path, tell the html which variable came from the activity.

I really do not know is it possible. That's why I need help. Thank you in advance for your attention.

    
asked by anonymous 11.09.2018 / 21:26

0 answers