开发者

Is there any API that i can distinguish between 3G Network and Wifi?

开发者 https://www.devze.com 2023-01-24 04:31 出处:网络
I am working with my ipad app. With 开发者_运维百科my iPad 3G,it\'s a trouble that i can\'t solve. I want to distinguish between 3G network and wifi in my app. Anyone had encountered the same problem

I am working with my ipad app. With 开发者_运维百科my iPad 3G,it's a trouble that i can't solve. I want to distinguish between 3G network and wifi in my app. Anyone had encountered the same problem before? any advice welcomed! Thanks!


You want the "reachability" API that is discussed here.


This should help:

http://www.drobnik.com/touch/2010/08/reachability/


You can use this to distinguish 3G or WIFI network~

//For 3G check
boolean is3g = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
        .isConnectedOrConnecting();
//For WiFi Check
boolean isWifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
        .isConnectedOrConnecting();
0

精彩评论

暂无评论...
验证码 换一张
取 消