Вопрос

How can I get the remaining time until screenOff? I don't mean the value of timeout setting, but how much time remains until screenOff(if user haven't touch the screen). Some kind of checking every 2-3 secs.

Это было полезно?

Решение

You can get the default screen timeout set by the system using this:

android.provider.Settings.System.getInt(getContentResolver(),Settings.System.SCREEN_OFF_TIMEOUT,-1);

So you have the default timeout and the last time the user touched the device. With this you can approximate the time left for the screen to turn off.

Though i am not sure how you would handle user touches to the NotificationBar which would reset the timeout.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top