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();
}
}
What is Android?
What is the difference between match_parent and fill_parent?
What is Intent? What is the difference between an implicit intent and an explicit intent?
Explain Fragment Life Cycle
How to extract date and time from Long type variable in Kotlin on Android "
What are the notifications available in android?
What is ANR? How to avoid and resolve it?
How to start a new activity on button click
Android Activity FullScreen - How to set activity to fullscreen mode in Android?
How to convert milli seconds to hours, minutes and seconds in Android?
ERROR Android emulator gets killed when I try to run my application and choose an emulator it ret
How to get an image resource by it's name in android?
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
How can i comment inside xml file in android studio?
ERR_ACCESS_DENIED in Android Webview with sdk 30
How do I generate random numbers in Dart?
Permission denied for window type 2010 in Marshmallow device
How to add jar/library files as a dependency in Android studio gradle file
How to check Android version?
What is Context?
How do i load image from drawable folder in Jetpack Compose?
What is NetworkOnMainThread Exception?
How to save activity State in Android?
'constructor Handler()' is deprecated. Deprecated in Java, How to use Handler() class in And
Intent for Drive PDF Viewer - How to open PDF in Google Drive with intent
Hide/Disable soft keyboard on Activity launch: Android
How do I check in SQLite whether a table exists?
How to copy database from assets folder in android using kotlin
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
Key Points to remember while develop the Android Application.
What is the Different Between val and var in Kotlin?
How to find Android Device UDID or unique ID?
How to reduce APK package size?
Duplicate files during packaging of APK” build.gradle issue: Android Studio
How to stop EditText focus at Activity startup in Android?
How to Generate signed apk with android studio
Android Studio project R can't find
How To Set Text Color Programmatically Android TextView?
How to avoid multiple button click at same time in android?
What is ANR in android?