문제

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