Detecting GPRS network availability in android
I am using Ksoap to call my web service & i display a progressDialog while i get the response. But if i enter a area where there is no network, it continues searching for the network (The progress dialog doesnt stop.. i need 2 ForceStop my app ). I have caught Exception in my Ksoap callin开发者_C百科g method.. but no exception is thrown...
cud any1 help how do i fix this ..
This dint solve my issue. It always returns true for isConnected(). Finally i am now using below code in my Ksoap Class (with ksoap2-android-assembly-2.5.4-jar-with-dependencies ) to detect timeout, which i guess is helping me out. Need 2 do some more testing.
HttpTransportSE androidHttpTransportSE; int TimeOut=180000; androidHttpTransportSE = new HttpTransportSE(URL,TimeOut); androidHttpTransportSE.call(soap_action, envelope);
SoapObject response = (SoapObject)envelope.bodyIn; reply = response.toString();
any 1 having a better solution ?
You can query the ConnectivityManager (Connectivity Service) to give more information on if the data network is available or not.
http://developer.android.com/reference/android/net/ConnectivityManager.html#getActiveNetworkInfo()
getActiveNetworkInfo() method would give you more information on the current network connected to.
精彩评论