简体   繁体   中英

Android 3G Connection

When i am using wifi network all is working fine ,,but when i turn off all network(Not Airplance mode) and turn on 3G HotSpot then my application is not even detecting connection.So web service shwoing timeout errors.

ConnectivityManager cm = (ConnectivityManager)getSystemService
(Context.CONNECTIVITY_SERVICE);;
boolean 3GCon=cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected()

This returning always false

为什么不尝试使用isAvailable()而不是isConnected()?

很难给出一个确切的答案,说明它为什么不适合你,但作为一个开始,我建议你看一下这个例子,比如这个ConnectivityManagerTestActivity ,并将它与你自己的代码进行比较。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM