由网友(薰衣草ヾ带着紫色dē忧伤)分享简介:我有一个Android应用程序中,有一个特殊的要求,凡在我需要检查,如果Android设备具有网络提供商或它只是WiFi功能。I have an android app, in that there is a particular requirement where in I need to check if the...
我有一个Android应用程序中,有一个特殊的要求,凡在我需要检查,如果Android设备具有网络提供商或它只是WiFi功能。
I have an android app, in that there is a particular requirement where in I need to check if the Android device has a network provider or its just WiFi enabled.
感谢你。
推荐答案
这应该可以解决问题。
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if(networkInfo != null && networkInfo.isConnected()){
//Your code here
}
相关推荐
最新文章