I want to know how to draw something on top on screen without permission request.
I had implement an app can draw something on the top on screen by this post, it worked fine before my device version update to 6.0.
When my app run on devices above 6.0, I met a permission issue that I need to ask user to request SYSTEM_ALERT_WINDOW permission in app as this post says, and it worked fine when I implement the permission request code.
But I found many apps can draw many things on top of screen without this permission on google play store, like Draw on screen, Screen Draw Screenshot, etc.
How can I implement this function with permission like these apps?
Can someone help me?
just set target sdk version = 22 and you can do it without asking permission.
Btw it is not a good practice you should absolutely use the new Runtime Permission of 6.0
Related
An important feature of our app (which blocks certain distracting apps) is to block the uninstallation of apps when the user wants to. This is working perfectly on Android 11 and below, but on Android 12 and up this isn't working anymore.
The way we block apps is through placing an overlay through the WindowManager using TYPE_APPLICATION_OVERLAY as parameter type. The SYSTEM_ALERT_WINDOW permission is granted and the overlay is showing for all cases, except for when the user uninstalls the app. I tested with Android 12, and the package installer ("com.google.android.packageinstaller" on Pixel) that uninstalls the apps is recognized by our app, and our app also tries laying out the overlay over it. No exceptions occur, there are no logcat messages, but the overlay is simply not displayed. The overlay is displayed correctly over all other apps it should be displayed over.
So it seems to me that Android 12 doesn't allow an app overlay to be displayed over the package installer. Android 12 blocks untrusted touch events compared to Android 11, but this shouldn't affect this behaviour. I couldn't find any documentation on related changes in Android 12, so do you have some pointers to whether we can still block the package installer on Android 12?
I am trying to make an app that its behavior was like cover app, where I can show clocks, answer or reject a call, control music and more.
But I have problems with Android Oreo.
In previous versions I could do it with the indicator TYPE_SYSTEM_ERROR, and with this indicator I could put my view above all the other views, including, on the view of the call.
But with Android Oreo I try to do the same with TYPE_APPLICATION_OVERLAY.
It partially work, but It doesn´t work with phone screen, with this flag when a call is incoming the native call screen is on top of my app, and I dont want that.
I can put my app on priv_app folder. And I can have system permissions.
What can I do?
The error is,
the code is,
Android states i must ask for permission if my app wants to "Draw over other apps" when on Android v 6.0+. This permission can only be given manually by the user navigating to the appropriate Settings area.
When sent to Settings (via my app calling the intent) i noticed the "Draw over other apps" option for my app is always set to Disabled; it cannot be modified. Furthermore, if one were to navigate to the Apps permissions manually you'll notice the desired app isnt even listed in the "Draw over other apps" page making it impossible to adjust the setting.
I've already followed the baffling instructions by others to disable all the other apps listed then to try running my app again but to no luck. I've also tried restarting the emulator, factory reset, and other emulators. No luck.
Are there any other solutions to resolving this disabled issue?
Ok i discovered the problem and this is likely the same issue all others have had. Within my AndroidManifest.xml i forgot to include the SYSTEM_ALERT_WINDOW permission.
So add the following just before the application element:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
Problem solved. Everyone should ignore the ridiculous claim that you need to disable all the other Draw over apps or Force stop others. Completely unnecessary in my case.
I am developing an application which requires location permission for Android Marshmallow. I followed all the steps (function calls) required to implement that.
When I run the application it pop up a box asking for the user permission. When I select yes, it display another pop up saying "Screen overlay detected" and that takes me to setting screen where list of applications is shown. There I uncheck all the applications and press back button to return to my app.
When onRequestPermissionsResult() callback is called, I can see the permission is not granted. It happen all the time.
Why does it display "screen overlay detected" all the time as I have already unselected/unchecked all the apps in the list?
Why permission is not granted although I have pressed yes when it ask for the permission?
The reason: This message appears when you’re running a floating app, and then start a newly installed one, which requests access rights. Floating apps include the chat heads of Facebook Messenger that can appear floating above other apps, etc.
Affected Smartphones: Users across the internet have reported experiencing this problem on Samsung and Motorola smartphones. It seems likely to affect many manufacturers. AndroidPIT managed to replicate the behavior on a Vodafone and a Samsung smartphone.
Problem apps: We replicated the problem using Drupe, but CleanMaster, Lux and Twilight have all been blamed for the problem.
The technical background: As a security measure, apps ask for permission to use certain parts of your phone (internal storage, camera, etc.). In theory, a display overlay can interfere with the dialogue requesting permission, so you need to disable the feature to interact with the dialogue.
Now the Solution, how to fix it:
Step one: "Screen overlay detected" fix
Find you what apps have permission to draw over the screen. On a non-Samsung smartphone, follow these steps:
Open the Settings
Tap the search icon at the top right
Enter the search term “draw”
Tap Draw over other apps
Select Draw over other apps
For Samsung users:
Open the Settings
Then Applications > Application manager
Press on More > Apps that can appear on top
Step two:
You will find yourself in front of a list of apps that have permission to use floating buttons or other screen overlays. Now you need to identify the problem app and temporarily deny it permission to draw over the screen. Here is are some pointers on how to identify the app that’s causing trouble:
Do you see an app bubble on your screen? If do, this app is almost certainly the cause. Either you hide the app bubble or disable the app in the list
Do you have an app installed that changes the colors on the display or adjusts the brightness?
Reportedly, Clean Master can be a trouble maker. If you see Clean Master in the list, disable it
If there’s no obvious cause, disable everything
Step three:
Now you can try launching the app again, and it should request permissions without the “Display overlay detected” error getting in the way.
For Samsung users: The one-handed keyboard setting could be the root cause. Deactivate it by going to Settings> Advanced features > One-handed operation.
Step four: reactivate screen overlays
In order for the app(s) that you have disabled in step two to work again, you need to re-enable its overlay permissions. If you turned off all apps, it might be worth considering only reactivating those apps that you actually use.
This is a rather inelegant workaround, but it's the best we have until Google makes the necessary changes to prevent app overlays from interfering with permission dialogues.
Has this guide helped? If you are still experiencing the error after following our guide, leave a comment, so I can try and address the problem.
This is the issue reported many times.
The possible solutions are:
1) delete apps like(cleanmaster, battery saver, etc.) or go to settings/app/cleanmaster/force stop.
2) Or you can also remove the permissions for cleanmaster.
3) determine which app is drawing over other apps. Turn that off beforehand.
Note: Sometimes unchecking does not actually solve the problem of the overlay.
Is seems like the current way to exclude apps from the recent apps-lists in android L is broken. Our app is using android:excludeFromRecents and it works just fine. Unless our app is the FIRST app to start when the device reboots.
This is how it looks when our app is exited as the first app on the device:
And here is how it looks if we first start the camera (or any other app), then our app and exit both:
Simply put: If an app with android:excludeFromRecents is started as the first app on the device, the directive android:excludeFromRecents isn't working. If another app has been started before the android:excludeFromRecents-app, it works as expected.
Is this a really weird edge-case bug or am i'm missing something very obvious here?
We build a very privacy cautious web browser (http://inbrowserapp.com), so we cannot have any screenshots from the app showing once the app is closed. But this should also affect banking-apps, password-managers etc since sensitive information will be screenshotted if the app is the first to start after a reboot.
Maybe we can go about the route and hide the sensitive information with a blank view when the user is exiting on Android L. But its seems like something is buggy here?
I'm happy to say that this is fixed for Android 5.1. Just confirmed it on a device running 5.1.
So the correct solution, for us anyways, is to deny screenshots with getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); for Lollipop with SDK version 21, anything below or above that should be fine.
You can at least prevent the screenshot in recents by setting this flag:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
But it's still a bug that never should have made it to release..