java - Create a synchronize HTTP GET request in Android -
I am trying to get some text through HTTP and display it on the UI. I do not need an async function (i.e., the user will have to wait until I can get the text completely.)
I tried to do it in the main thread
try {string url = URL_HERE; HttpGet httpget = New HttpGet (url); ResponseHandler & LT; String & gt; FeedbackHandler = new basicshandler (); Text = Client.execute (httpget, responseHandler); } Hold (exception before) {text = ex.getLocalizedMessage (); } But I always see an exception. To get the lesson I just need a simple mechanism Can you suggest?
Thank you very much,
You should use asyncatsk but if you Try to use a sync method
string result = execute (). Get () ToString ();
This will freeze the UI (no application responds) until you get the message from httpget
Comments
Post a Comment