簡體   English   中英

總是凍結在httpwebresponse上,無法執行任何操作

[英]always freeze at httpwebresponse and cannot do anything

HttpWebRequest webRequest = WebRequest.Create("http://127.0.0.1/login.php?id=boonjye91") as HttpWebRequest;

HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse;
response.Close();
// Read the response
StreamReader reader = new StreamReader(response.GetResponseStream());
var responseText = reader.ReadToEnd();

// This just shows the server's response, but you'll probably want to do other things
Toast.MakeText(this, responseText, ToastLength.Long).Show();

當我運行斷點時。 我發現它在網絡響應中卡住並凍結了。 為什么呢?

嘗試在Asyntask中運行它,並在onPostExecute()方法中獲得所需的結果。

http://developer.android.com/reference/android/os/AsyncTask.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM