1

I have custom Alarm Clock Application. When the alarm triggering, my Activity starts. That works on Android 9, but doesn’t work on Android 10 from background [Restrictions on starting activities from the background][1]. Google suggests launching notifications instead of activity, but I don’t quite understand how to display the alarm triggering using notifications. Are there any other solutions to display the alarm triggering?

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
vargaadam
  • 411
  • 5
  • 18
smikhlevskiy
  • 33
  • 1
  • 7
  • https://stackoverflow.com/a/58819729/115145 – CommonsWare Nov 22 '19 at 12:03
  • thanks, It works good for locked screen. But it not work when screen not locked. I can find solution when app in foreground, but not know how display alarm screen when screen not locked and app in background. Any ideas? Only by notifications? – smikhlevskiy Nov 25 '19 at 16:27
  • "But it not work when screen not locked" -- it works, but it does not do what you want. What you want is what Google does *not* want. "Only by notifications?" -- yes. – CommonsWare Nov 26 '19 at 00:13
  • Thanks for the help! I implemented all the necessary functions of the alarm window using "full screen intent" and "heads-up" notifications – smikhlevskiy Nov 27 '19 at 12:12

0 Answers0