LibreShift / red-moon

Android screen filter app for night time phone use.
GNU General Public License v3.0
653 stars 82 forks source link

Updating FilterService to no longer crash on start on Android O #318

Closed automaton82 closed 2 years ago

automaton82 commented 2 years ago

Right now if you start red-moon on Android O without the draw on top permission, the app will crash after 5 seconds. The cause of this is explained here:

https://stackoverflow.com/questions/44425584/context-startforegroundservice-did-not-then-call-service-startforeground

Essentially:

"The system allows apps to call Context.startForegroundService() even while the app is in the background. However, the app must call that service's startForeground() method within five seconds after the service is created."

Android O behaviour change -- https://developer.android.com/about/versions/oreo/android-8.0-changes.html