naresh
naresh

Reputation: 155

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 coding problem how can i handle it?

Please can anybody help me.

thanks

Upvotes: 1

Views: 553

Answers (1)

Sujit
Sujit

Reputation: 10632

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

} 

Upvotes: 2

Related Questions