这是在android上。我正在创建如下的本地通知:
public final static String ONGOING_CALL = "ONGOING_CALL";
public static void displayOngoingCallNotification(String calleeNames,String msg) {
try {
LocalNotification n = new LocalNotification();
n.setId(ONGOING_CALL);
n.setAlertBody(msg);
n.setAlertTitle("Calling "+calleeNames);
Display.getInstance().scheduleLocalNotification(
n,
System.currentTimeMillis() + 500, // fire date/time
LocalNotification.REPEAT_NONE // Whether to repeat and what frequency
);
} catch (Exception ex) {
ex.printStackTrace();
}
}
稍后以编程方式取消:
public static void dismissOngoingCallNotification() {
try {
System.out.println("Going to dismiss ongoing call");
Display.getInstance().cancelLocalNotification(ONGOING_CALL);
System.out.println("ongoing call dismissed");
} catch (Exception ex) {
System.out.println("Trouble, can't dismiss ongoing call");
ex.printStackTrace();
}
}
然而,在我手动点击之前,通知仍然存在。我在这里缺少什么?