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();
}
}
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
Extract Date and Time from Long Type Variable - RRutors
What are the notifications available in android?
Decompile APK Files: How to Get Source Code - RRutors Guide
What is the Different Between val and var in Kotlin?
Hide/Disable soft keyboard on Activity launch: Android
Fix Android Emulator Kill Error When Running Your App
How to stop EditText focus at Activity startup in Android?
How to validate email address in Android with Kotlin?
What is Android?
How to convert DP to Pixel and Pixel to Dp?
What are Android Versions available?
How to start a new activity on button click
How to copy database from assets folder in android using kotlin
How to Get bitmap from drawable: Android
How to get a contact image using a phone number in android?
How to get complete address from latitude and longitude?
What is Android Fragments?
Invoke-customs are only supported starting with android 0 --min-api 26
How To Set Text Color Programmatically Android TextView?
Check List for Generate Signed APK Android
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
How to install/ uninstall apk by command line ADB
How to reduce APK package size?
How do i load image from drawable folder in Jetpack Compose?
What is the difference between match_parent and fill_parent?
How to save activity State in Android?
Fix Play Store Rejection Due to SMS Permission - RRutors
How do I check in SQLite whether a table exists?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
What is NetworkOnMainThread Exception?
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to check Android version?
Android Studio project R can't find
How to find Android Device UDID or unique ID?
What is Intent? What is the difference between an implicit intent and an explicit intent?
Set Activity to Fullscreen Mode in Android - RRutors
How can i comment inside xml file in android studio?
How to get screen size (width,height) in Android?