How to call the event "screen_off", when running my app?
How 开发者_如何学Goto call the event "screen_off", when running my app? for example 5 seconds after the start
in displayOffTime=5*1000;//5 seconds
following code will make screen off after 5 seconds
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, displayOffTime);
This will turn the screen off for the specified amount of time:
PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);
manager.goToSleep(int amountOfTime);
精彩评论