我想從webviewin Android獲取返回值。我使用webview.postUrl
來發布價值,但如何獲得我在PHP回聲的結果?有誰能夠幫助我?謝謝。 這裏是我的代碼如何從webview獲取結果值?
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";
}
發佈您的代碼.. – Aerrow 2012-07-21 03:22:04