是否应在ToastBar中显示LocalNotification Id?
我创建了一个本地通知:
LocalNotification ln = new LocalNotification();
ln.setId("geofence entered");
ln.setAlertTitle("Welcome");
ln.setAlertBody("Please proceed to the building");
Display.getInstance().scheduleLocalNotification(ln,
System.currentTimeMillis() + 1000, LocalNotification.REPEAT_NONE);它正确地触发并向我显示具有正确标题和正文的通知。然而,如果我点击它,当它打开应用程序时-在ToastBar中显示Id "geofence entered“。如果删除.setId("geofence entered"),则不会显示通知,并收到错误消息:
2021-07-13 17:15:40.009 21809-21809/io.jarvisapp.app E/Codename One: background location error
java.lang.IllegalArgumentException: Notification ID must be set
at com.codename1.ui.Display.scheduleLocalNotification(Display.java:4804)
at io.jarvisapp.app.geofence.GeofenceListenerImpl.onEntered(GeofenceListenerImpl.java:131)其中,第131行是Display.getInstance().scheduleLocalNotification(ln, System.currentTimeMillis() + 1000, LocalNotification.REPEAT_NONE);
我怎么能不在ToastBar中显示id?提前谢谢你。
发布于 2021-07-17 00:44:10
由于@Shai对回调代码的评论,导致问题的代码片段被找到了。我完全忘记了在我的主类中使用以下方法实现了LocalNotificationCallback:
@Override
public void localNotificationReceived(String notificationId) {
GeneralUtil.showToastBarMessage(notificationId,3000,0);
}https://stackoverflow.com/questions/68369493
复制相似问题