Added network bug workaround

This commit is contained in:
M66B
2019-12-23 16:47:46 +01:00
parent f1ef60d0c8
commit aabae2d8d6

View File

@@ -187,7 +187,13 @@ public class ConnectionHelper {
Network active = cm.getActiveNetwork();
if (active == null) {
Log.i("isMetered: no active network");
return null;
// Workaround bug in some Android versions
NetworkInfo ani = cm.getActiveNetworkInfo();
if (ani == null || !ani.isConnected()) {
Log.i("isMetered: no active network=" + (ani == null ? null : ani.isConnected()));
return null;
}
return cm.isActiveNetworkMetered();
}
// onLost [... state: DISCONNECTED/DISCONNECTED ... available: true]