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 "shared preferences" in Android ?
Android Studio project R can't find
How to stop EditText focus at Activity startup in Android?
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
What is ANR? How to avoid and resolve it?
Android FCM not receiving notifications when app is removed from background
How do i load image from drawable folder in Jetpack Compose?
Could not inflate Behavior subclass android.support.design.widget. BottomSheetBehavior How resolve
How to start a new activity on button click
'constructor Handler()' is deprecated. Deprecated in Java, How to use Handler() class in And
How can i comment inside xml file in android studio?
Intent for Drive PDF Viewer - How to open PDF in Google Drive with intent
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How To Set Text Color Programmatically Android TextView?
Invoke-customs are only supported starting with android 0 --min-api 26
How to install/ uninstall apk by command line ADB
How to Get bitmap from drawable: Android
What is Android Fragments?
How to find Android Device UDID or unique ID?
Permission denied for window type 2010 in Marshmallow device
What is Intent? What is the difference between an implicit intent and an explicit intent?
How do I check in SQLite whether a table exists?
How to get complete address from latitude and longitude?
How to copy database from assets folder in android using kotlin
How to extract date and time from Long type variable in Kotlin on Android "
How to get a contact image using a phone number in android?
Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path
How to check Android version?
What is Context?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
Duplicate files during packaging of APK” build.gradle issue: Android Studio
What are the notifications available in android?
Is There A Way To Get The Source Code From An APK File? (or) How to decompile apk?
How to get an image resource by it's name in android?
What are symmetric and asymmetric encryption in the way Android interacts with the server?
What is NetworkOnMainThread Exception?
How to Generate signed apk with android studio
How to convert milli seconds to hours, minutes and seconds in Android?
What is the difference between match_parent and fill_parent?
What is Application?