tags:

views:

13

answers:

1

dear friends,

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();
A: 

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://stackoverflow.com/questions/3075506/http-connection-timeout-on-android-not-working

Rahul
but i am not using http request call for webservice but ksoap libary.
UMMA
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
Rahul
yes i have seen it but it not seems to be working :( and many other people complaining about it too.
UMMA