I am using PowerManager.WakeLock
to wake my screen up when a notification appears...
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, getClass().getName());
//Acquire the lock
wl.acquire();
NotificationCompat.Builder nb = new NotificationCompat.Builder(context);
nb.setContentTitle("Title");
nb.setContentText("This is a notification test.");
nb.setSmallIcon(R.drawable.ic_launcher);
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
final Intent notificationIntent = new Intent(context.getApplicationContext(), ShowReminderActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
final PendingIntent contentIntent = PendingIntent.getActivity(context.getApplicationContext(), 0, notificationIntent, 0);
nb.setContentIntent(contentIntent);
Notification notification = nb.getNotification();
notification.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(0, notification);
//Release the lock
wl.release();
This wakes up the screen when on notification, but the screen wake up is only a blink. I tried wl.acquire(Long.valueOf(5000))
but that did not extend the screen wake up.
How do I extend the screen wake up duration?
Thank you!
try {
Thread.sleep(1000);//or however long this is one second
} catch (InterruptedException e) {
e.printStackTrace();
}