How can I make Sleep stay in the foreground?

Sleep as Android used to stay in the foreground when tracking. So when I woke in the night, when I turned on the phone, the tracking screen was displayed and I coul easily pause tracking or whatever.
Now the app is pushed to the background and the home screen is always the first screen I get to. It makes getting back to the app difficult when half asleep.
This is the latest version on Android 10.

Hello, on standard Android devices the sleep tracking screen stays in the foreground all night. But I guess you have one of the problematic devices with firmware modification to standard Android. What is you Phone OEM? Please check here on how to resolve such issues https://dontkillmyapp.com/

Many thanks…

It’s a Nokia 6.1 and used to keep the app running in the foreground. I’ll recheck the link

There were big battery management issues on Nokia 2 years ago - with the Evenwell and Duraspeed task killers, but to our knowledge and thanks to pressure from DKMA project Nokia recalled this software from all wast majority of their phones…

I remember that. The thing is that sleep tracking is not being killed, it just isn’t easily accessible by remaining in the foreground, so the app is not displayed when turning on the screen.

You mean the lock screen is displayed instead? This is normal the app respects your device screen timeout… if you want to keep sleep tracking on front all the time you would need to enable Settings > Sleep tracking > Adavcned > Screen dimming > Always on clock…

No I use Tasker to disable the screen lock. So when I press the power button, sleep tracking used to be the first thing I saw. Now it is home screen. I didn’t have to use the screen dim settings within Sleep to keep the screen on.

Oh I got you this time… this is because Android 10 does not allow apps anymore to start screens from the background… to workaround this you need to grant the app permission to draw over other apps in Settings > Apps > SaA > Advanced…

That is already enabled.

So how are you starting sleep tracking?

From either the bedtime notification or from the app itself.

Sorry I’m still having troubles to understand the issue. So you say that you start sleep tracking with the Moon button from the app, but the sleep tracking screen does not start you only see a Moon icon in the status bar which indicates that the sleep tracking service is started but not the screen? Is this the case…

Or the screen starts but after some time it is somehow hidden by the system?

  • I start sleep tracking by either notification or sleep tracking button in the app.
  • I press the power button or let screen timeout so screen is off.
  • If I immediately turn the screen back on, or after a few minutes, the tracking screen is the first screen I see.
  • At some point, the tracking app is minimised to background.
  • When I wake up after a few hours, home screen is what I see when I turn on the screen.

I think I know what @23deano means.

I have granted the permission to draw over other apps to Sleep as Android. What OP is describing is indeed the default behavior for me: after initiating sleep tracking, the tracking screen will still be at the foreground whenever I turn the screen back on.

I don’t really like it for fear of accidental presses during the night by either me or my pet, so usually I switch back to the home screen after initiating tracking. I’ll give it a go tonight and see if it persists on the foreground after a while and/or when I wake up.

Is the app whitelisted from battery saving tasks? Ain’t there any other automated task from Tasker or whatever scheduled to run during the night?

I have SD Maid and a Tasker alternative set to run late in the night and I wouldn’t put it beyond them to mess with foreground apps, specially given that I’m quite liberal with the draw over apps permission when asked.

The actual sleep tracking is working as intended for me, though.

@marioho, yes that is exactly what I mean.
Thanks for the tip about whitelisting for battery optimisation, I hadn’t considered that. The app was being optimised, so I have switched that off. I shall see how it goes tonight.

@23deano my theory is that the phone probably spontaneously reboots during the night… but I would need to see the “menu - report a bug” log to confirm… I hope Nokia is now using the standard Android (AOSP) battery optimization mechanism and this should have no effect on keeping activities in foreground - unless Nokia would do something special in this case which woudl be interesting for the https://dontkillmyapp.com/ project…

I finally remember to test it this night. Went to bed with the tracking screen on the foreground. When I woke up, it was right there still, business as usual.

Mine is a LG Velvet running Android 10