Open TytaniumDev opened 10 years ago
Hey Tyler,
I actually am using AlarmManager (see https://github.com/jrobinson3k1/Path-of-Exile-Racer/blob/master/src/com/jasonrobinson/racer/util/AlarmUtils.java) that triggers AlarmReceiver ( https://github.com/jrobinson3k1/Path-of-Exile-Racer/blob/master/src/com/jasonrobinson/racer/receiver/AlarmReceiver.java). So I think I should be in decent shape, though I've noticed alarms aren't very precise and I've noticed them being off by up to a minute.
I don't have any experience using AlarmManager, so I'm not on top of it ins and outs, so maybe you can answer a couple questions for me. Will alarms persist if the phone is rebooted? Is that why you're using BOOT_COMPLETED? What are the benefits of handling setting and canceling alarms through a service like you've done?
Thanks,
Jason
On Sun, Feb 9, 2014 at 8:08 PM, Tyler Holland notifications@github.comwrote:
Sorry for not being able to contribute, I haven't had much time to work on side projects. I might have a couple of weeks between race seasons when I can help out.
Just saw your 1.2 update, and it looks great! I really like the expandable days in the race list.
You might have some trouble using Countdowntimer to do the race notifications, as it won't save its state when the phone is shut down or if for some reason your app is killed. I'd recommend using AlarmManager, it's pretty easy to set up and it'll restart all of the alarms when a device is restarted for you.
You could probably pretty easily take my code and copy+paste with some small tweaks to get it working in yours, the classes you want to look at EventAlarmReceiver, Service, and Setter. Also look at my manifest file, the BOOT_COMPLETED intent-filter is needed for the restart stuff. You'll also need to add something to your database to keep the list of races to set alarms for. I did this by just adding another column in my Race table, but you might just want to use a different table so if you update a race it won't mess with the alarm flag.
Let me know if you have any questions, here's a link to the alarm service class https://github.com/Tywholland/PoEEvents/blob/master/src/com/tywholland/poeevents/EventAlarmService.java
Reply to this email directly or view it on GitHubhttps://github.com/jrobinson3k1/Path-of-Exile-Racer/issues/3 .
Jason Robinson
Oh I completely missed your Alarm classes, yeah those look great. Alarms don't persist if the device is rebooted, which is the only reason I have this class https://github.com/Tywholland/PoEEvents/blob/master/src/com/tywholland/poeevents/EventAlarmSetter.java
The only reason I put everything in an IntentService is because that's how I saw it being done in the examples I looked up. I'm not completely sure about this, but maybe you have to use a service so that the receiver you call when the device reboots can re-set all of the alarms without having to launch the whole app? That's the only reason I can think of right now.
I see what you mean. Force closing the app or rebooting the phone cancels any alarms. I'll need to put in a fix for this. Thanks!
On Mon, Feb 10, 2014 at 6:11 PM, Tyler Holland notifications@github.comwrote:
Oh I completely missed your Alarm classes, yeah those look great. Alarms don't persist if the device is rebooted, which is the only reason I have this class https://github.com/Tywholland/PoEEvents/blob/master/src/com/tywholland/poeevents/EventAlarmSetter.java
The only reason I put everything in an IntentService is because that's how I saw it being done in the examples I looked up. I'm not completely sure about this, but maybe you have to use a service so that the receiver you call when the device reboots can re-set all of the alarms without having to launch the whole app? That's the only reason I can think of right now.
Reply to this email directly or view it on GitHubhttps://github.com/jrobinson3k1/Path-of-Exile-Racer/issues/3#issuecomment-34712796 .
Jason Robinson
Sorry for not being able to contribute, I haven't had much time to work on side projects. I might have a couple of weeks between race seasons when I can help out.
Just saw your 1.2 update, and it looks great! I really like the expandable days in the race list.
You might have some trouble using Countdowntimer to do the race notifications, as it won't save its state when the phone is shut down or if for some reason your app is killed. I'd recommend using AlarmManager, it's pretty easy to set up and it'll restart all of the alarms when a device is restarted for you.
You could probably pretty easily take my code and copy+paste with some small tweaks to get it working in yours, the classes you want to look at EventAlarmReceiver, Service, and Setter. Also look at my manifest file, the BOOT_COMPLETED intent-filter is needed for the restart stuff. You'll also need to add something to your database to keep the list of races to set alarms for. I did this by just adding another column in my Race table, but you might just want to use a different table so if you update a race it won't mess with the alarm flag.
Let me know if you have any questions, here's a link to the alarm service class https://github.com/Tywholland/PoEEvents/blob/master/src/com/tywholland/poeevents/EventAlarmService.java