private static void updateNotification(
...
//sOpMessagingNotification.onUpdateNotification(isNew);
wakeUpScreen(context);
}
/**
* M: Wake up screen
* @param context
*/
private static void wakeUpScreen(Context context) {
...
// 去掉在插入耳机的状况下才会唤醒判断
// if (hasInsertedHeadSet || headsetIsOn) {
}
// add Wake up screen
private PowerManager.WakeLock wakeLock;
private void wakeUpScreen() {
if (wakeLock== null){
wakeLock= mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, TAG);
wakeLock.setReferenceCounted(false);
}
if (!mPowerManager.isScreenOn()) {
wakeLock.acquire(3000);
Log.d(TAG, "notification turn screen on");
}
}
}
//end
在addNotificationViews和updateNotificationInternal里面添加如下亮屏请求,当来了一条新通知或者更新一条通知的时候都会走到这两个逻辑
protected void addNotificationViews(NotificationData.Entry entry){
if (entry == null) {
return;
}
// Add the expanded view and icon.
mNotificationData.add(entry);
tagForeground(entry.notification);
updateNotifications();
+ wakeUpScreen();
}
private void updateNotificationInternal(StatusBarNotification notification,
NotificationListenerService.RankingMap ranking) throws InflationException {
...
updateHeadsUp(key, entry, shouldPeek, alertAgain);
updateNotifications();
+ wakeUpScreen(); // add
}
本文地址:https://blog.csdn.net/wxd_csdn_2016/article/details/107978255
如对本文有疑问, 点击进行留言回复!!
SpringBoot实现本地存储文件上传及提供HTTP访问服务的方法
Java实现AES/CBC/PKCS7Padding加解密的方法
SpringBoot整合Spring Security的详细教程
IDEA 非常重要的一些设置项(一连串的问题差点让我重新用回 Eclipse)
详解Springboot2.3集成Spring security 框架(原生集成)
网友评论