Reputation: 1606
How to call the event "screen_off", when running my app? for example 5 seconds after the start
Upvotes: 1
Views: 743
Reputation: 10810
This will turn the screen off for the specified amount of time:
PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);
manager.goToSleep(int amountOfTime);
Upvotes: 0
Reputation: 15477
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);
Upvotes: 1