检测android中的GPRS网络可用性
我正在使用 Ksoap 来调用我的网络服务 &我在收到响应时显示进度对话框。但是,如果我进入没有网络的区域,它会继续搜索网络(进度对话框不会停止..我需要 2 ForceStop 我的应用程序)。我在 Ksoap 调用方法中捕获了异常..但没有抛出异常...
cudany1 帮助我如何解决这个问题..
这解决了我的问题。 isConnected() 始终返回 true。最后,我现在在 Ksoap 类中使用下面的代码(使用 ksoap2-android-assemble-2.5.4-jar-with-dependencies )来检测超时,我想这对我有帮助。需要 2 做更多测试。
HttpTransportSE androidHttpTransportSE; int超时=180000; androidHttpTransportSE = new HttpTransportSE(URL,超时); androidHttpTransportSE.call(soap_action, 信封);
SoapObject 响应 = (SoapObject)envelope.bodyIn; 回复=response.toString();
任何1有更好的解决方案吗?
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 calling 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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查询 ConnectivityManager(连接服务)以提供有关数据网络是否可用的更多信息。
http://developer.android.com/reference/android/net/ConnectivityManager .html#getActiveNetworkInfo()
getActiveNetworkInfo() 方法将为您提供有关当前连接的网络的更多信息。
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.