Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know device is connected to Wifi or 3G, programatically

How i can know device is connected to Wifi or 3G, programmatically

Thanks

like image 994
praveenb Avatar asked Aug 11 '10 17:08

praveenb


People also ask

How do you check if WiFi is on or off in android programmatically?

Checking the state of WiFi can be done by obtaining an instance to the WiFi system service as below: WifiManager wifi = (WifiManager)getSystemService(Context. WIFI_SERVICE); from this, the method isWifiEnabled() can be used to determine if WiFi is enabled.

How do I know what network im connected to?

Go to settings. Click on connections (or similar option). Find the Wifi option. This should reveal what network you are connected to.


1 Answers

you can use WifiManager class as mentioned here

Edit: by calling getConnectionInfo() function of WifiManager class you will get WifiInfo object

WifiInfo has function getBSSID() which gives you connected AP's name

if its null that means it is not connected to any AP via Wifi ( Wifi is not enabled )

btw while looking for more info, i found this which should answer all your questions about mobile connectivity and wifi connectivity

like image 61
N30 Avatar answered Oct 06 '22 00:10

N30