1

I'm a CodeNameOne beginner. I'm trying to make a local notification, it doesn't seem to work,I don't get anything displayed. here's the start function. Is there anything missing? Should I add variables in the build settings?

    public void start() {
        if(current != null){
            current.show();
            return;
        }
        Form hi = new Form("Hi World", BoxLayout.y());
        hi.add(new Label("Hi World"));
        hi.show();
          LocalNotification n = new LocalNotification();
n.setId("demo-notification");
n.setAlertBody("It's time to take a break and look at me");
n.setAlertTitle("Break Time!");
//n.setAlertSound("/notification_sound_beep-01a.mp3");
    // alert sound file name must begin with notification_sound

Display.getInstance().scheduleLocalNotification(
        n,
        System.currentTimeMillis() + 10 * 1000, // fire date/time
        LocalNotification.REPEAT_MINUTE  // Whether to repeat and what frequency
);
    }
Compte Gmail
  • 137
  • 3
  • 8
  • Local notifications will only show when running on the device (not simulator). Are you running this on Android? iOS? If so which OS version? – Shai Almog May 15 '21 at 05:17
  • Hey Shai, I'm running through CodeNameOne's simulator. (If I'm not mistaking), How to show notifications on simulatoir then? – Compte Gmail May 15 '21 at 11:35
  • A notification is the thing you see when you pull down a menu in Android. I think what you're looking for is either ToastBar or Dialog. – Shai Almog May 16 '21 at 01:47

0 Answers0