ConnectivityManager.getBackgroundDataSetting()德precated,改用什么? [英] ConnectivityManager.getBackgroundDataSetting() deprecated, what to use instead?

查看:276
本文介绍了ConnectivityManager.getBackgroundDataSetting()德precated,改用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

previously人们可以使用:

Previously one could use:

ConnectivityManager.getBackgroundDataSetting();

要检查用户是否有后台数据设置= TRUE。现在这种方法去precated:

to check if the user had background data setting = true. This method is now deprecated:

http://developer.android.com/reference/android/net/NetworkInfo.html

文档说使用方法:

The docs say to use:

ConnectivityManager.getActiveNetworkInfo();

相反,它返回一个NetworkInfo对象,但什么是在的NetworkInfo等价检查呢?

instead, which returns a NetworkInfo object, but what's the equivalent check in NetworkInfo then?

感谢

推荐答案

如果 getActiveNetworkInfo(),你没有网络连接,或者是因为该设备没有网络连接,或者是因为用户的设置(例如带宽上限)prevent您的应用具有网络连接。

If getActiveNetworkInfo() is null, you do not have a network connection, either because the device does not have a network connection, or because user settings (e.g., bandwidth caps) prevent your app from having a network connection.

这篇关于ConnectivityManager.getBackgroundDataSetting()德precated,改用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆