检测从LocalNotification打开应用程序的时间

时间:2017-02-21 12:41:08

标签: codenameone

我想通过本地通知检测我的应用程序何时打开并阅读通知的ID,类似于推送通知类型3。

LocalNotification应根据其ID或任何隐藏值打开特定表单,但在点击时,它不会让听众读取它的标题,ID或正文。

以下是我的LocalNotification用法:

final LocalNotification ln = new LocalNotification();
ln.setAlertTitle("Booking request reminder:\n");
ln.setAlertBody(currentBooking.get("BookingDetails").toString());
ln.setAlertImage("/booking_image.jpg");
ln.setId(currentBooking.get("BookingId").toString());

Display.getInstance().scheduleLocalNotification(ln, System.currentTimeMillis() + 3600000, LocalNotification.REPEAT_NONE);

对我来说,实现这一点的任何想法或黑客都将受到赞赏。

1 个答案:

答案 0 :(得分:2)

在您的主课程中,您可以添加:

public class MyMainClass implements LocalNotificationCallback

然后,您可以覆盖该方法:

@Override
public void localNotificationReceived(String notificationId) {
    //do some stuff
}

以下是一些有用的链接:java docCN1's blog post

相关问题