-1

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";
}
user1434388
  • 77
  • 1
  • 13

1 Answers1

0

It looks like you want to make an HTTP request using a class such as HttpClient instead of using a WebView for it. Check out this question for information on using HttpClient.

Community
  • 1
  • 1
JohnD
  • 3,884
  • 1
  • 28
  • 40
  • the webview i using it for my website...why i need to get the response result,it is because i make login page in android and intent to this page and show webview for my website. i have to check the result for userid and password. – user1434388 Jul 21 '12 at 03:49
  • Then for making that login request to your website, instead of using the WebView, use the HttpClient and then use the WebView as normal. – JohnD Jul 21 '12 at 03:51
  • you mean using the httpclient to check my response userid and password then intent to my webview? i give it a try...then will give you the answer mark..thank you. – user1434388 Jul 21 '12 at 03:56