I am new to android and I have done an online chat app. The problem is when I request 'http post' repeatedly to refresh my chat screen, the app hangs and I cannot perform any other operations.
Asked
Active
Viewed 120 times
1
-
use AsyncTask and every time check Internet Connectivity if u have not done it. – Aamirkhan Sep 27 '12 at 04:39
-
no,I have done in main tread itself.How to do it in Async task – user1684892 Sep 27 '12 at 05:33
-
Have a look at this: http://stackoverflow.com/questions/9671546/asynctask-android-example – Bruno Bieri Sep 27 '12 at 05:37
-
Async task is giving unknown host exception – user1684892 Sep 28 '12 at 10:37
-
Thanks all.Async task worked.But now, after using async task getcount method in list adapter is infinitely looping and no other methods in list adapter is working. – user1684892 Oct 04 '12 at 05:35
1 Answers
0
Your Application freezes because you are performing a network operation within the Main Thread and you are blocking it.
This Asynctask tutorial and this blog will help you.
-
-
You can pass ListView in your AsyncTask. To get the result from AsyncTask, there is a method called onPostResult(Result) . so you can update your listview. Note: Don't update listview from doInBackground(). – Sep 29 '12 at 04:19