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();
}
}
How to Use Deprecated Handler() in Android - RRutors Guide
How to Generate signed apk with android studio
How to Exit android app on back pressed?
What is "shared preferences" in Android ?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
How to get an image resource by it's name in android?
What is the difference between match_parent and fill_parent?
What are the notifications available in android?
How to get complete address from latitude and longitude?
How to get screen size (width,height) in Android?
How do I check in SQLite whether a table exists?
Android Studio project R can't find
Open PDF in Google Drive with Intent in Android - RRutors
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
What happens next when the device switches between portrait and landscape?
Extract Date and Time from Long Type Variable - RRutors
How do I generate random numbers in Dart?
Check List for Generate Signed APK Android
What is Application?
How to install/ uninstall apk by command line ADB
How to avoid multiple button click at same time in android?
What is Android Fragments?
How can i comment inside xml file in android studio?
How to copy database from assets folder in android using kotlin
Explain Fragment Life Cycle
FCM Not Receiving Notifications in Android - RRutors
ERR_ACCESS_DENIED in Android Webview with sdk 30
What are Android Versions available?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
How to Get bitmap from drawable: Android
How do i load image from drawable folder in Jetpack Compose?
How to convert DP to Pixel and Pixel to Dp?
What is Intent? What is the difference between an implicit intent and an explicit intent?
What is Android?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
How to get a contact image using a phone number in android?
Decompile APK Files: How to Get Source Code - RRutors Guide
Hide/Disable soft keyboard on Activity launch: Android
What is Context?
What is the Different Between val and var in Kotlin?