I have a problem, I have one where I show a personalized Dialog, but for this type of Dialog I need the permissions like this:
But for the new versions of android I need to ask for the permissions in time of execution, so I took an example that I had done before with the location, but for this type of permission it does not work for me.
@RequiresApi(api = Build.VERSION_CODES.M)
public void accesoPermiso() {
statusPermiso = checkSelfPermission(android.Manifest.permission.SYSTEM_ALERT_WINDOW);
if (statusPermiso != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{android.Manifest.permission.SYSTEM_ALERT_WINDOW},
PERMISOALERTA);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case PERMISOALERTA:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//ubicarPorGps();
//Aqui el Permiso es concedido
} else {
Toast.makeText(this, "Permiso Denegado", Toast.LENGTH_SHORT).show();
}
break;
default:
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
In the example that I had done with location, it worked wonders, but when changing the permissions by SYSTEM_ALERT_WINDOW, it does not work and once at the start of the APP, once it jumps to the TOAST that says permission is denied and it does not show me the window to request permission.