Passing Data From Java to Webview Html (with javascript)

Android Bilgisayar ENGLISH DOCS Html Php Yazılım

Passing Data From Java to Webview Html

Passing Data From Java to Webview Html (with javascript)

we will send data from java (like android source) to html via webviev. We can use the following code to get what we need ;

1-Java side :

webview.getSettings().setJavaScriptEnabled(true); // we enable the javascript on device
webview.loadUrl("file:///android_asset/test.html"); //load the html file

webview.setWebViewClient(new WebViewClient(){ 
    public void onPageFinished(WebView view, String url){   //it is important ,must call on "onPageFinished" or you got nothing
        webview.loadUrl("javascript:init('" + latitute+ , +otherValue+ , + anothervalue + ,+ blahblah + "')");
    }           
});

2-Html side:




    This is a Tittle




 

 

3 -If you want to use it on Php side:

$val1->latitude= $_POST['latitude'];
$val2->othervalue= $_POST['othervalue'];
$val3->anothervalue= $_POST['anothervalue'];
$val4->blahblah= $_POST['blahblah'];

 

 

 

All done ;

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir