101k views
4 votes
Which permission is required for a broadcast receiver for the CONNECTIVITY_CHANGE action?

User Stroblme
by
7.8k points

1 Answer

3 votes

Final answer:

The required permission for a broadcast receiver for CONNECTIVITY_CHANGE is android.permission.RECEIVE_BOOT_COMPLETED. For apps targeting Android 7.0 (API level 24) or higher, the NetworkCallback mechanism or runtime registration for the receiver must be used.

Step-by-step explanation:

The permission required for a broadcast receiver for the CONNECTIVITY_CHANGE action in Android is called android.permission.RECEIVE_BOOT_COMPLETED. However, it's important to note that as of Android 7.0 (API level 24), apps can no longer register broadcast receivers for implicit broadcasts in their manifest.

Instead, apps targeting API level 24 and higher must use the NetworkCallback mechanism instead or register the receiver at runtime, not in the manifest, if they want to monitor for changes in network connectivity.

To listen for the CONNECTIVITY_CHANGE action, a broadcast receiver in Android needs to have the permission android.permission.ACCESS_NETWORK_STATE.

User Purplegoldfish
by
7.5k points