Get Network type

后端 未结 13 1087
后悔当初
后悔当初 2020-12-01 08:35

I\'ve been trying to retrive the current network type, but no success

when i say network type: i refer to know this info: if the type is: NETWORK_TYPE_IDEN

13条回答
  •  半阙折子戏
    2020-12-01 09:06

    In my experience... it's best to use Android training guides for these types of efforts. It's easy to get null pointer exceptions when you use these classes, and it's especially bad when you try to detect these connections when the app first opens and then the app crashes.

    You can use the ConnectivityManager to check that you're actually connected to the Internet, and if so, what type of connection is in place:

    http://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html

    You can use the ConnectivityManager to determine the active wireless radio:

    http://developer.android.com/training/efficient-downloads/connectivity_patterns.html

提交回复
热议问题