Question

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"?

Was it helpful?

Solution

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


  }

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top