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 do I check in SQLite whether a table exists?
How to install/ uninstall apk by command line ADB
What is Android Fragments?
Set Activity to Fullscreen Mode in Android - RRutors
Explain Fragment Life Cycle
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Invoke-customs are only supported starting with android 0 --min-api 26
How to start a new activity on button click
How to validate email address in Android with Kotlin?
How to get an image resource by it's name in android?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to find Android Device UDID or unique ID?
How to Generate signed apk with android studio
Permission denied for window type 2010 in Marshmallow device
How to Get bitmap from drawable: Android
What is NetworkOnMainThread Exception?
How to get a contact image using a phone number in android?
What are the notifications available in android?
How to Use Deprecated Handler() in Android - RRutors Guide
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How to save activity State in Android?
Fix Play Store Rejection Due to SMS Permission - RRutors
How to check Android version?
What is ANR? How to avoid and resolve it?
Android Studio project R can't find
Key Points to remember while develop the Android Application.
Add Jar/Library Files as Dependency in Android Studio
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to convert DP to Pixel and Pixel to Dp?
How to copy database from assets folder in android using kotlin
How can i comment inside xml file in android studio?
What are Android Versions available?
What is the difference between match_parent and fill_parent?
How to get complete address from latitude and longitude?
Check List for Generate Signed APK Android
What is the Different Between val and var in Kotlin?
What is Application?
What is ANR in android?
How to reduce APK package size?