0

i am using a web service to retrieve data inside a thread. so i start thread and call website in it. problem is i called service and INTERNET was present and then disconnected how can i stop that request and stop that thread in order to show message to user that there is not INTERNET coverage.

here is code of mine please help me out what should i do?

new Thread(new Runnable() {
                public void run() {

                    while (serviceData == null) {


                        DalMessages dal= new DalMessages();

                        serviceData = dal.getInboxConversationPosts(Session_ID, PageSize, 0);


                        callComplete = true;

                    }

                    mHandler.post(loadActivity());
                }

                private Runnable loadActivity() {
                    return new Runnable() {
                        public void run() {

                            if(callComplete)
                            {
HideLoadingAnimation();
}
}
                    };
                }
            }).start();
DeRagan
  • 22,827
  • 6
  • 41
  • 50
UMAR-MOBITSOLUTIONS
  • 77,236
  • 95
  • 209
  • 278

1 Answers1

0

You can set a Timeout for your call so that if you do not get a response from the server over a certain period of time an exception will be thrown and you can show a message to the user.

Http connection timeout on Android not working

Community
  • 1
  • 1
DeRagan
  • 22,827
  • 6
  • 41
  • 50
  • but i am not using http request call for webservice but ksoap libary. – UMAR-MOBITSOLUTIONS Sep 28 '10 at 09:27
  • Did you check whether this class can help you ? http://ksoap2.sourceforge.net/doc/api/org/ksoap2/transport/HttpTransport.html http://stackoverflow.com/questions/1473810/how-do-i-enforce-a-timeout-on-a-webservice-call-using-ksoap-2 – DeRagan Sep 28 '10 at 09:57
  • yes i have seen it but it not seems to be working :( and many other people complaining about it too. – UMAR-MOBITSOLUTIONS Oct 16 '10 at 12:18