I am developing an app that allows a user to connect to a specific wifi network using the google vision api to scan a QR code containing an ssid. To scan for wifi networks I need to request the user to grant the location permission. This all works fine if i go to the settings and manually enable the Location permission but when requesting the permission at run-time, the user taps enable then a second dialog pops up, Screen Overlay Detected
which requires a context switch to enable the Screen Overlay
permission. I am not drawing over other apps and when i manually enable the location permission there is no problems. So why is this permission dialog popping up?
As I am not sure why Android is asking for this permission i am not sure what code to post. i have included the request for the 3 required permission for the change network request.
final int permissionCheck = ContextCompat.checkSelfPermission(mActivity, Manifest.permission.CAMERA);
final int locationPermissionCheck = ContextCompat.checkSelfPermission(mActivity, Manifest.permission.ACCESS_COARSE_LOCATION);
final int wifiPermissionCheck = ContextCompat.checkSelfPermission(mActivity, Manifest.permission.CHANGE_WIFI_STATE);
final int granted = PackageManager.PERMISSION_GRANTED;
if ((permissionCheck != granted) || (locationPermissionCheck != granted) || (wifiPermissionCheck != granted)) {
ActivityCompat.requestPermissions(mActivity, new String[]{
Manifest.permission.CAMERA,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.CHANGE_WIFI_STATE
}, 0);
} else {
cameraSource.start(cameraView.getHolder());
}
Update
Turns out its not just the location permission that trips it up. Any permission request is experiencing the same behaviour.