Read remaining time until screen goes off

Hello community
I want to disconnect bluetooth when my android goes into stand by. I would like to know how much time is left. I'm sure someone has an idea how to approach this problem
Greetings Stefan

Use the ActivityChamged event from the tools extension to disconnect bluetooth


Great it works. Thanks

But the question remains whether you can read out the remaining time until the screen goes dark

It is possible to read the total time from the settings. But I haven't found a method to read the remaining time. It could work so that the app checks the touch of the screen and counts down the timeout from the last touch of the screen.

The remaining time (from when?) until the screen goes dark?

Play around with the following blocks and customize them according to your intentions.

Why? To what extent does it help you if you know that the device switches to idle mode after 2 or 4 or 7 minutes?

As I showed earlier, you must query the lifecycle and also whether the device has been put into idle mode or just moved to the background.