Search code examples
androidandroid-wificonnectivity

What is the alternative to getBackgroundDataSetting


When I tried to use:

connectivity.getBackgroundDataSetting();

Eclipse says it is deprecated. So, is there any alternative?


Solution

  • from the docs for ConnectivityManager.html#getBackgroundDataSetting()

    This method was deprecated in API level 14. As of ICE_CREAM_SANDWICH, availability of background data depends on several combined factors, and this method will always return true. Instead, when background data is unavailable, getActiveNetworkInfo() will now appear disconnected.

    So above API 14, just check that getActiveNetworkInfo() is not null and use that as your boolean.