JavaEar 专注于收集分享传播有价值的技术资料

ConnectivityManager.getBackgroundDataSetting()过时,而不是用什么? (ConnectivityManager.getBackgroundDataSetting() deprecated, what to use instead?)

Previously one could use:

ConnectivityManager.getBackgroundDataSetting();

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();

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

Thanks

1个回答

    最佳答案

  1. 英文原文

    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.


    中文翻译

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

    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.

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