Reputation: 463
Intro: Using the getTypeName() method returns the human readable String value of a network information examined. Trying to locate the possible returned values led me to ConnectivityManager's getNetworkTypeName method.
Some of the values returned can be: "MOBILE_DUN", "WIMAX", "BLUETOOTH", "ETHERNET", etc...
Question: What are the values i should consider when asking if the device is connected?
Question: If, for instance, i'm connected with "MOBILE_DUN" or "ETHERNET", am i still considered connected with "MOBILE"/"WIFI"?
Upvotes: 1
Views: 1405
Reputation: 463
Question: What are the values i should consider when asking if the device is connected?
Answer: The values can be found in ConnectivityManager.getNetworkTypeName(int type) method.
Question: If, for instance, i'm connected with "MOBILE_DUN" or "ETHERNET", am i still considered connected with "MOBILE"/"WIFI"?
Answer: The answer is yes. It seems your device can be connected to a number of these networks simultaneously.
Upvotes: 0
Reputation: 679
try this code;
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if(cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
.isConnectedOrConnecting()
|| cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
.isConnectedOrConnecting())
{
// do functionality
}
Upvotes: 2