Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为Android 10开发定制闹钟_Android_Android 10.0 - Fatal编程技术网

为Android 10开发定制闹钟

为Android 10开发定制闹钟,android,android-10.0,Android,Android 10.0,我有定制的闹钟应用程序。当警报触发时,我的活动开始。 这在安卓9上有效,但在后台安卓10上不起作用[从后台启动活动的限制][1]。 谷歌建议启动通知而不是活动,但我不太明白如何使用通知显示警报触发。是否有其他显示报警触发的解决方案 final PendingIntent alarmIntent = getAlarmActivityIntent(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Pendin

我有定制的闹钟应用程序。当警报触发时,我的活动开始。 这在安卓9上有效,但在后台安卓10上不起作用[从后台启动活动的限制][1]。 谷歌建议启动通知而不是活动,但我不太明白如何使用通知显示警报触发。是否有其他显示报警触发的解决方案

final PendingIntent alarmIntent = getAlarmActivityIntent();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    PendingIntent showIntent = getShowIntent();
    AlarmManager.AlarmClockInfo info = new AlarmManager.AlarmClockInfo(ringAt, showIntent);
    if (am != null)
     am.setAlarmClock(info, alarmIntent);```


  [1]: https://developer.android.com/guide/components/activities/background-starts#display-notification

谢谢,它适用于锁定屏幕。但当屏幕未锁定时,它不工作。我可以找到解决方案时,应用程序在前台,但不知道如何显示报警屏幕时,屏幕未锁定和应用程序在后台。有什么想法吗?仅通过通知?“但当屏幕未锁定时它不工作”——它工作,但它不做您想要的事情。你想要的是谷歌不想要的。“仅通过通知?”--是的,谢谢你的帮助!我使用“全屏意图”和“抬头”通知实现了报警窗口的所有必要功能。谢谢,它适用于锁定屏幕。但当屏幕未锁定时,它不工作。我可以找到解决方案时,应用程序在前台,但不知道如何显示报警屏幕时,屏幕未锁定和应用程序在后台。有什么想法吗?仅通过通知?“但当屏幕未锁定时它不工作”——它工作,但它不做您想要的事情。你想要的是谷歌不想要的。“仅通过通知?”--是的,谢谢你的帮助!我使用“全屏意图”和“提示”通知实现了报警窗口的所有必要功能