I used the code from post #1. He works fine except for one exception. Android 8.0 has a problem with my app. For "android:targetSdkVersion = '26' ", opening the overlay window will result in an error. The change to "android:targetSdkVersion = '23' " prevents the occurrence of this error. I was informed by hints from users of my app. This behavior has been confirmed by a test in the Android 8.0 emulator (Android SDK).