当设备处于睡眠/空闲模式时,通知不会生成

时间:2017-02-26 12:03:42

标签: android

我正在从服务类生成通知。代码在这里

SharedPreferences userPreferences = PreferenceManager.getDefaultSharedPreferences(context);
String defaultRingTone = "content://settings/system/notification_sound";
String alarms = userPreferences.getString("notifications_new_message_ringtone", defaultRingTone);
Uri ringToneUri = Uri.parse(alarms);
notificationBuilder.setSound(ringToneUri);
// Play default notification sound
// Vibrate if vibrate is enabled
boolean isVivbrate = userPreferences.getBoolean("notifications_new_message_vibrate", true);
notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notificationID, notificationBuilder.build());

问题是当设备处于空闲/睡眠模式通知时没有生成,当我立即手动唤醒设备时,我收到所有待处理的通知。我在android L和M中遇到此问题。我也尝试通过唤醒锁生成通知并更改通知优先级但未找到任何解决方案。

有什么方法可以解决这个问题吗?

0 个答案:

没有答案
相关问题