Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass a value to loadURL - Android

Is it possible to pass a value to the URL mentioned in webView.loadUrl? something like this??

webView.loadUrl("file:///android_asset/www/index.html#value="+value);

or is there any way to pass a Java String value to the Javascript function in loadURL?

like image 641
Naveen Avatar asked Dec 03 '11 15:12

Naveen


1 Answers

I found the solution.. posting it here for the sake of others :)

I added the following snippet of code in my Activity class which solved the problem,

webView.setWebViewClient(new WebViewClient() {  
                @Override  
                public void onPageFinished(WebView view, String url)  
                {  
                    webView.loadUrl("javascript:callMe(\""+data_val+"\")");

                }  
            });  

Thanks all :)

like image 185
Naveen Avatar answered Sep 28 '22 04:09

Naveen