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.