Hi all,
How i can know device is connected to Wifi or 3G, programmatically
Thanks
Hi all,
How i can know device is connected to Wifi or 3G, programmatically
Thanks
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
You have to check the network info e.g. like this
private boolean isOnline() {
ConnectivityManager connectivityManager = (ConnectivityManager)
getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
boolean connected = networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnected();
return connected;
}