I checked mobile network connection in my program and I followed the discussion in this link. My code is as follow.
boolean internet_flag = true;
ConnectivityManager conMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mobile = conMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (!mobile .isAvailable())
{
internet_flag = false;
}
if(internet_flag == false)
{
Toast.makeText(this, "Internet connection is down, please check netwrok connection", Toast.LENGTH_LONG)
.show();
}
I turned off Mobile data at my handphone and my wifi is connected to a WiFi-based SDcard reader device (so I am sure that I have no Internet connection), but I still have internet_flag == true. My questions are
(1)Why I still have internet_flag == true even though I turned it off.
(2)I would like to understand the internet connection in Android. According to this discussion when Wifi is on, 3G is automatically off (it is still true?). In the discussion, to get 3G connection back, Wifi is turned off again. In my case, I can't switch off Wifi as I have it connected to the SDcard reader, but I still want to force to 3G connection. How can I do that? Possible Thanks