When we want to display an overlay window on the Phone screen in Android version 6 and above this exception will come. To fix this issue follwo below steps Check Manifest file with below permission Check Permission Granted for Android 6(Marshmallow and above devices) and above with below code Check Permision Request Result
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
public booleancheckOverLayPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, OVERLAY_PERMISSION_CODE);
return false;
}else
{
return true;
}
}else
{
return true;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == OVERLAY_PERMISSION_CODE) {
if (Settings.canDrawOverlays(this)) {
// SYSTEM_ALERT_WINDOW permission not granted...
Intent serviceIntent = new Intent(Homepage.this, ChatHeadService.class);
serviceIntent.putExtra("removeUserId", friendId);
startService(serviceIntent);
} else {
Toast.makeText(MyProtector.getContext(), "ACTION_MANAGE_OVERLAY_PERMISSION Permission Denied", Toast.LENGTH_SHORT).show();
}
}
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
Extract Date and Time from Long Type Variable - RRutors
What are Android Versions available?
How to Get bitmap from drawable: Android
What is "shared preferences" in Android ?
Add Jar/Library Files as Dependency in Android Studio
How to check Android version?
Check List for Generate Signed APK Android
How to validate email address in Android with Kotlin?
How to Use Deprecated Handler() in Android - RRutors Guide
How do I generate random numbers in Dart?
How to Exit android app on back pressed?
Fix Android Emulator Kill Error When Running Your App
What are the notifications available in android?
FCM Not Receiving Notifications in Android - RRutors
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to avoid multiple button click at same time in android?
How to copy database from assets folder in android using kotlin
Invoke-customs are only supported starting with android 0 --min-api 26
What is Android?
What is Context?
How to install/ uninstall apk by command line ADB
Hide/Disable soft keyboard on Activity launch: Android
Set Activity to Fullscreen Mode in Android - RRutors
How to reduce APK package size?
What is the Different Between val and var in Kotlin?
How to start a new activity on button click
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
Open PDF in Google Drive with Intent in Android - RRutors
How to get screen size (width,height) in Android?
What is Intent? What is the difference between an implicit intent and an explicit intent?
How to get an image resource by it's name in android?
Explain Fragment Life Cycle
What is Android Fragments?
Android Studio project R can't find
How to convert milli seconds to hours, minutes and seconds in Android?
How to stop EditText focus at Activity startup in Android?
Decompile APK Files: How to Get Source Code - RRutors Guide
What is ANR? How to avoid and resolve it?