I want to get a return value from webviewin Android. I used webview.postUrl
to post value, but how to get result that i echo in the php? Can anybody help me? Thanks.
here is my code
String url = "http://192.168.0.20/exe/test/aaa/test.php";
String postData = "uID=md5_id&uPWD=md5_pass";
WebView webview = (WebView) findViewById(R.id.webview);
WebSettings webviewSettings = webview.getSettings();
webviewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webviewSettings.setJavaScriptEnabled(true);
webviewSettings.setSavePassword(false);
webviewSettings.setSaveFormData(false);
webviewSettings.setSupportZoom(true);
webview.setWebChromeClient(new WebChromeClient());
webview.postUrl(url, EncodingUtils.getBytes(postData, "utf-8"));
php is as below show,
$uID=$_POST['uID'];
$uPWD=$_POST['uPWD'];
//echo "$uID : $uPWD";
if($uID==$uPWD){
echo "ok";
}else{
echo "fail";
}