1

我是 CodeNameOne 初学者。我正在尝试发出本地通知,它似乎不起作用,我没有显示任何内容。这是开始功能。有什么遗漏吗?我应该在构建设置中添加变量吗?

    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
);
    }
4

0 回答 0