Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to cancel the alarm clock #11

Open
hyitclj opened this issue Nov 26, 2015 · 5 comments
Open

How to cancel the alarm clock #11

hyitclj opened this issue Nov 26, 2015 · 5 comments

Comments

@hyitclj
Copy link

hyitclj commented Nov 26, 2015

How to cancel the alarm clock

@se1exin
Copy link

se1exin commented Jan 8, 2016

Just reading the source code and it appears to cancel all existing alarms whenever window.wakeuptimer.wakeup() is called. I'm guessing you pass and empty 'alarms' array in the call and it will cancel all alarms. A pretty terrible way to 'cancel an alarm' imo, but I guess its better than nothing :\

@nine-2-five
Copy link

Hi @se1exin, I'm having trouble removing the alarms the way you described (by passing an empty array). Is there another way?

@se1exin
Copy link

se1exin commented Nov 23, 2016

Hi @isvaljek, its been nearly a year since I've used this plugin so I may be wrong on this..

Looking at the Android source for WakeupPlugin.java, if you call snooze the plugin will eventually call cancelAlarms - which will cancel all alarms. Directly beneath the cancel the plugin then re-schedules the alarms - BUT if you pass it an empty array, nothing gets rescheduled, effectively just cancelling all alarms. Note you MUST pass the snooze function an alarms array, or it will throw an error and not cancel the alarms.

So I would do something like this:

window.wakeuptimer.snooze(
    successCallback,
    errorCallback,
    {
        alarms : []
    }
 );

Good luck!

@nine-2-five
Copy link

Thanks @se1exin , but it seems that the cancelAlarms leaves behind a couple of alarms. I'm not sure but if I clear the alarms the way you describe, and then set a single 7-day alarm, I always end up getting one or two previously cleared dates (ghosts) when I run adb shell dumpsys alarm. It seems that clearing daylist type of alarms always leaves last alarm day set.

@se1exin
Copy link

se1exin commented Nov 25, 2016

@isvaljek I get ya. Sorry but it's been too long so I'm of no more help help here :( Best I can suggest is fork the repo and add the functionality you need

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants