Five Min BG scheduling

I think this should work... in my onTimerStart() method once an Activity is started. I could put this in onStart() instead so it does this even before the Activity starts?

What I think this should do is fire off my BG process immediately if the last time didn't exist or is more than 5 mins ago.

Since that is a MOMENT, that is a one time trigger. Then go ahead and also setup an EVERY FIVE MINS Duration event, regardless of if I have started an immediate event or not.

Any timing issues with this logic?

                //////////////////////////

                var lastTime = Background.getLastTemporalEventTime();

                var FIVEMINS = new Time.Duration(5 * 60);
                if (lastTime == null || Time.now().greaterThan(lastTime.add(FIVEMINS))) {
                    System.println("Background Event triggered right now");
                    Background.registerForTemporalEvent(Time.now());
                }
                System.println("Background Event scheduled every 5 minutes");
                Background.registerForTemporalEvent(FIVEMINS);