- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,我在我的 android 项目中使用了 phonegap 本地通知插件。通知效果很好。我可以删除带有 ID 的通知但在我的应用程序中,我必须删除所有通知选项,为此插件提供了取消所有通知的方法。这是:-
plugins.localNotification.cancelAll();
但这行不通。我在这里使用这个插件 https://github.com/phonegap/phonegap-plugins/tree/master/Android/LocalNotification任何帮助将不胜感激。
最佳答案
我认为这可能是这个问题的答案。正如它在 cancelAllNotifications()
方法(LocalNotification.java 第 124 行)的描述中所说:
Android can only unregister a specific alarm. There is no such thing as cancelAll. Therefore we rely on the Shared Preferences which holds all our alarms to loop through these alarms and unregister them one by one.
但是,请看一下调用 cancelAllNotifications()
方法的代码(第 59 行):
} else if (action.equalsIgnoreCase("cancelall")) {
unpersistAlarmAll();
return this.cancelAllNotifications();
}
这是 unpersistAlarmAll()
的样子(第 181 行):
private boolean unpersistAlarmAll() {
final Editor alarmSettingsEditor = this.cordova.getActivity().getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit();
alarmSettingsEditor.clear();
return alarmSettingsEditor.commit();
}
正在发生的事情是,在 cancelAllNotifications()
被调用之前,alarmIds 正在从 sharedPreferences 中清除,实际上没有要取消的警报。
我不确定将调用移至 unpersistAlarmAll()
的最佳位置在哪里,我很乐意得到一些建议。同时,在测试从 alarm.cancelAll(alarmSettings)
返回的结果(第 133 行)后,我将其移至 cancelAllNotifications()
内,如下所示:
if (result) {
unpersistAlarmAll();
return new PluginResult(PluginResult.Status.OK);
到目前为止,这似乎工作正常。也许另一种方法是废弃整个 unpersistAlarmAll()
方法,而是在成功取消每个单独的警报后调用 unpersistAlarm(String alarmId)
(第 168 行)。
关于android - phonegap android 本地通知 cancelAll 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13697015/
在下面的代码中,在 CancelAll 和 Stop 之后,之后添加到队列中的请求将在启动命令之后立即执行。 如何删除插入队列中的最后一个/多个请求? final RequestQueue
我已经面临这个问题很长时间了,我有一个具有很多功能的应用程序,其中之一就是闹钟 我的通知只是停留在那里,永远不会消失尽管我正在打电话cancelAll()/cancel()从通知管理器,我也有 aut
在 android 通知管理器类中有两个函数 cancel() 和 cancelAll() 不管我定义了什么 notifcationManager 因为我仍然无法取消推送的通知。此通知服务在应用程序打
我有 Cordova 应用程序,带有本地通知插件。问题是 cancelAll() 不会等到它完成,因此当我添加新消息时它仍在删除。 如何同步线程以使 cancelAll() 等待? 一些相关代码Ala
您好,我在我的 android 项目中使用了 phonegap 本地通知插件。通知效果很好。我可以删除带有 ID 的通知但在我的应用程序中,我必须删除所有通知选项,为此插件提供了取消所有通知的方法。这
使用 NotificationManagerCompat 取消所有通知。 NotificationManagerCompat manager = NotificationManagerCom
我正在使用 Delphi DX Seattle 并在 Android 设备上进行测试 当用户单击按钮时,我正在创建多个计划通知 当用户单击另一个按钮时,我会清除剩余的通知 我似乎无法让 TNotifi
这是我的 onComplete。 $('#fine-uploader-house').fineUploader({ ... }).on('complete', function(event, id,
我是一名优秀的程序员,十分优秀!