Screen on and then off too fast when using WakeLock (not remaining on for a few second)
<p>I'm facing a problem using Wake lock through PowerManager API.
Currently, i have a service and a broadcast receiver.</p>

<p>My service has 2 main roles :</p>

<ul>
<li>First one, it creates an alarm at a specific time (my receiver receives the boot completed intent from system and start the service to create the next alarm)</li>
<li>Second one, the receiver reacts to the alarm (in RTC_WAKEUP mode) and start the service to play a notification by turning on the screen.</li>
</ul>

<p>I'm using Mark murphy's cwac-wakeful module to achieve that and it works just fine.</p>

<p>The problem is : the screen turns on and off too fast for the user to see it.</p>

<p>Here is what's happening when the alarm intent is launched (for the second role/case) : </p>

<ul>
<li>OnReceive method of Broadcast receiver is called</li>
<li>It calls WakefulIntentService.sendWakefulWork</li>
<li>My wakeLock is acquired (with SCREEN_DIM_WAKE_LOCK  | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE flags)</li>
<li>Screen is turned on</li>
<li>The service is launched : The notifications is created and displayed</li>
<li>Service finishes</li>
<li>Wake lock is released</li>
<li>Screen is turned off immediatly (not on after release for a few seconds)</li>
</ul>

<p>As you have probably understood. The problem is, the lock is released too fast after the service finishes so i can just see the screen turning on and off in less that one second.
I thought that using the  ON_AFTER_RELEASE (the doc says : "If this flag is set, the user activity timer will be reset when the WakeLock is released, causing the illumination to remain on a bit longer. This can be used to reduce flicker if you are cycling between wake lock conditions. ") would have solved my problem, but no.</p>

<p>When googling, i found a solution that consists in :</p>

<ul>
<li>Not releasing the wake lock just
after the service finishes but
launching another alarm in the next
15/20sec (from when service finishes)
that would release the wakelock (via
receiver/service) and turn off the
screen. I don't know if it'a good
solution and it seems complicated to
me for this use case</li>
</ul>

<p><em><strong>Then my question is how can i maintain the screen on for a few seconds (say 10/15 sec) like when i receive an sms, what is the best solution to achieve that ?</em></strong></p>

<p>Any help would be greatly appreciated, and thanks in advance !</p>
