我想从webviewin Android获取返回值。我使用webview.postUrl
发布值,但是如何获得我在php中回显的结果?有谁能够帮我?谢谢。
这是我的代码
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如下所示,
$uID=$_POST['uID'];
$uPWD=$_POST['uPWD'];
//echo "$uID : $uPWD";
if($uID==$uPWD){
echo "ok";
}else{
echo "fail";
}