I'm trying to get the new ConnectivityManager.bindProcessToNetwork(Network)
using ConnectivityManager.requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)
The reason is to force the app to call the future request in some specific network, which doesn't have a internet connectivity (it's a local hardware communication network). At this point, the system is sending the requests over 3G/4G network and never reach the desired Wifi network, because this network doesn't respond the connectivity check that android call.
When I call the requestNetwork
method, I receive the following error:
java.lang.SecurityException: com.xyz.app was not granted either of these permissions: android.permission.CHANGE_NETWORK_STATE, android.permission.WRITE_SETTINGS.
I try to call the new method to request permission available in Android 6.0:
requestPermissions(new String[]{Manifest.permission.CHANGE_NETWORK_STATE, Manifest.permission.WRITE_SETTINGS}, PERMISSIONS_REQUEST_WIFI);
But the callback is always PackageManager.PERMISSION_DENIED
.
I put both of these permissions in the AndroidManifest.xml
, without success.
Notice: The Manifest.permission.WRITE_SETTINGS
is not in the Permissions Groups.
WRITE_SETTINGS
is handled via a different mechanism. In terms ofCHANGE_NETWORK_STATE
, I am not sure what the story is there -- the docs claim it isnormal
, but my 6.0-equipped Nexus 5 says it issignature
.signature
permission unless you are signed by the same signing key as whatever is defending itself with that permission, or unless there is some other mechanism (e.g., howWRITE_SETTINGS
andSYSTEM_ALERT_WINDOW
are handled now).