If the crash is directly on your line:
return cm.getActiveNetworkInfo().isConnectedOrConnecting();
then that means getActiveNetworkInfo()
returned null
, because there is no active network — in that case, your isConnected()
method should return false
.
More Related Contents:
- Detect whether there is an Internet connection available on Android [duplicate]
- Android marshmallow request permission?
- Exception ‘open failed: EACCES (Permission denied)’ on Android
- How to detect incoming calls, in an Android device?
- Android M – check runtime permission – how to determine if the user checked “Never ask again”?
- How to check Grants Permissions at Run-Time?
- SYSTEM_ALERT_WINDOW – How to get this permission automatically on Android 6.0 and targetSdkVersion 23
- How can I programmatically open the permission screen for a specific app on Android 6.0 (Marshmallow)?
- How to programmatically enable auto start and floating window permissions
- How to request permissions from a Service in Android Marshmallow
- How to check MIUI autostart permission programmatically?
- Android M Camera Intent + permission bug?
- How to access the camera from within a Webview?
- How Do We Distinguish Never-Asked From Stop-Asking in Android M’s Runtime Permissions?
- Optional permissions so an app can show on all devices and enable optional features on some?
- android kotlin java.io.FileNotFoundException: /storage/emulated/0/number.txt: open failed: EACCES (Permission denied)
- How to detect Bluetooth state change using a broadcast receiver?
- Boot BroadcastReceiver does not work on Xiaomi devices
- Permission denied (missing INTERNET permission?): But permission is given
- Android Marshmallow: Changing permissions at run time crashes app
- Signing my android application as system app
- Dial number without prompt
- Push notifications (GCM) permission at runtime?
- Provide custom text for Android M permission dialog
- Android 6.0 Permission Denial: requires permission android.permission.WRITE_SETTINGS
- Answer Incoming Call in Android 6.0
- WRITE_EXTERNAL_STORAGE when targeting Android 10
- Android 13 – READ_EXTERNAL_STORAGE_PERMISSION still usable
- How to obtain MANAGE_EXTERNAL_STORAGE permission
- Permission denied on writing to external storage despite permission