android - How to handle the Web service exception
In my application i getting the exceptions when i am calling the web service. The exceptions are
07-11 18:46:54.942: INFO/System.out(1180): Webservice calling error ->java.net.UnknownHostException: Host is unresolved: www.roadbrake.com:80
07-11 18:46:54.942: INFO/System.out(1180): Soap Method Error ->java.lang.NullPointerException
is it code problem or Web service problem. if it is c开发者_如何学Gooding problem how can i handle it?
Please can anybody help me.
thanks
You should check your network connection before calling web service..
here is the code to check Network Connection...
ConnectivityManager conMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
if ( conMgr.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED
|| conMgr.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTING ) {
//notify user you are online
}
else if ( conMgr.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED
|| conMgr.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED) {
//notify user you are not online
}
精彩评论