I am new to Android, but i know somewhat in Java, and Java EE
While communicating with the Server(webservice) , it works fine with the response i am getting from it.
But if there is any time delay more than 5 seconds, it is going to ANR
. Now my question is how to check with my java functionality , to know whether the server is responding or not responding . Any ideas in this??
Even some Related examples will help me.
Code Snippet
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
// Problem is if Server is not Working , it delays and the UI wents to ANR
if( sendToWebservice(String_to_send)=="fromWebservice") {
Toast.makeText(context, "Connected", 500).show();
}
else {
Toast.makeText(context, "Not Connected,Try again ", 500).show();
finish();
}
}
}, 5000);
Additional Info:
I am using jax.ws
to create webservice
& ksoap api
in Android.
Thanks in Advance.
Edit
if( sendToWebservice(String_to_send).equalIgnorecase("fromWebservice") instead of ==
I missed to put this while framing it into syntax here..!!