2

I use NetworkInfo.isConnected() to determine if my app can make a web request:

public boolean isConnected() {
    ConnectivityManager connectivityManager =
            (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
    activeNetwork != null && activeNetwork.isConnected();
}

After the addition of Data Saver in Android N, is this method still reliable. In other words, if my app is restricted in the background on a metered network will isConnected() still return true?

tir38
  • 9,810
  • 10
  • 64
  • 107
  • I assume it will still return "connected" even when restricted. You can test it out by using adb commands to simulate device as unplugged and in saver mode – Alex.F Oct 29 '18 at 13:48
  • And the `adb` commands can be found here: https://developer.android.com/training/basics/network-ops/data-saver – Martin Marconcini Oct 29 '18 at 19:03

0 Answers0