相关疑难解决方法(0)

奥利奥没有显示通知

普通通知生成器不会在Android O上显示通知.

如何在Android 8 Oreo上显示通知?

是否有任何新代码要添加以在Android O上显示通知?

android android-notifications android-8.0-oreo

171
推荐指数
9
解决办法
13万
查看次数

如何在Android中安排通知

我正试图在将来设置通知.我有创建通知的代码,但我找不到安排它的选项.

我该如何安排通知?

java notifications android android-notifications

31
推荐指数
2
解决办法
4万
查看次数

Android O和后台限制可防止简单的警报通知

我自己的应用程序使用与2016年Google I/O应用程序所示的完全相同的技术.请参阅源代码

我需要在非常具体的时间点提醒用户 - 使用通知.

为此,我使用它AlarmManager在正确的时间点唤醒设备:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        am.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, alarmTime, pendingIntent);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        am.setExact(AlarmManager.RTC_WAKEUP, alarmTime, pendingIntent);
    } else {
        am.set(AlarmManager.RTC_WAKEUP, alarmTime, pendingIntent);
    }
Run Code Online (Sandbox Code Playgroud)

pendingIntent是这样创建的:

    final Intent intent = new Intent(MyAlarmService.ACTION_NOTIFY_RIDE, null, this, MyAlarmService.class);
    pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Run Code Online (Sandbox Code Playgroud)

现在,我的MyAlarmService类是一个简单的IntentService处理唤醒只是为了为用户创建通知.

我在日志中收到的消息如下:

W/ActivityManager: Background start not allowed: service Intent { act=xxx.xxx.xxx.action.NOTIFY_RIDE flg=0x4 cmp=xxx.xxx.xxx./xxx.xxx.xxx.service.MyAlarmService (has extras) } 
Run Code Online (Sandbox Code Playgroud)

现在,谷歌自己的实施显然已被打破 - 即使我不想做任何繁重的背景工作,我也不能再使用这种技术了.但是,我应该如何在非常具体的时间点唤醒用户呢?(想想我的应用程序作为闹钟)

wakeup alarmmanager android-notifications android-8.0-oreo

16
推荐指数
2
解决办法
1万
查看次数