I want to design an application and want some ideas

Put your problem here if it does not fit any of the other categories.

I want to design an application and want some ideas

Postby shentongascu » Fri Mar 16, 2012 3:06 pm

The application is just like a curriculum schedule and will have the following functions:

users can set the time of each course in a week.
users can choose how long before they will be warned about the beginning of courses.
users can choose how many times they will be warned and the time period.
In my opinion, I want to use AlarmManager to do this and define a BroadcastReceiver to deal with the alarm event. But after some thinking, I don't think it is a good idea, because ,for example, if I have 3 courses in a week and I want it to remind me for 3 times before the beginning of the course, that is to say I need to define 9 PendingIntent to realize this function. So I hope someone else can provide me with some other ideas and I would really appreciate it.
shentongascu
Freshman
Freshman
 
Posts: 2
Joined: Fri Mar 16, 2012 3:01 pm

Top

Re: I want to design an application and want some ideas

Postby Phyll » Fri Mar 16, 2012 4:46 pm

Hi shentongascu,

Regarding the alarms. It seems to me that you would only need one repeating alarm that executes at the resolution of your warnings. In other words, if you have one minute resolution on your warnings it would execute every minute and if there was an alarm set for that minute, it would execute. You could do it for even finer resolution but it would make the processor even more busy.

A more complicated way might be to have a chain of alarms with only the first alarm in the chain using an intent. When that alarm is triggered, it is removed from the chain and makes the intent for the next one.

Just a couple of ideas. Also, a note about alarms, they do not survive a power down. If it is important, you will need to be able to put them back.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: I want to design an application and want some ideas

Postby shentongascu » Fri Mar 16, 2012 5:35 pm

Phyll wrote:Hi shentongascu,

Regarding the alarms. It seems to me that you would only need one repeating alarm that executes at the resolution of your warnings. In other words, if you have one minute resolution on your warnings it would execute every minute and if there was an alarm set for that minute, it would execute. You could do it for even finer resolution but it would make the processor even more busy.

A more complicated way might be to have a chain of alarms with only the first alarm in the chain using an intent. When that alarm is triggered, it is removed from the chain and makes the intent for the next one.

Just a couple of ideas. Also, a note about alarms, they do not survive a power down. If it is important, you will need to be able to put them back.

Hope this helps.

Phyll

Thanks for your solutions. As you've said, the first way will produce a large burden to the processor, and I have to use a service to deal with this in background. So it seems not a good idea.
For the second one, to tell the truth, I got something confusing. what is an alarm? I mean, the AlarmManager just uses a PendingIntent to define an alarm service and get it linked to a broadcastReceiver to respond the time-up event, and there is no object named alarm. So could you make a explanation for that? please do not mind my asking, I am just a rookie and really want to finish this project.
oh, just add something. For the problem that an alarmservice will not work after the rebooting, I've already know how to do. just define a broadcastReceiver to respond the BOOT_COMPLETED message and rectify the alarm service, make them recovered.
anyway, thanks again
shentongascu
Freshman
Freshman
 
Posts: 2
Joined: Fri Mar 16, 2012 3:01 pm

Re: I want to design an application and want some ideas

Postby Phyll » Thu Mar 22, 2012 8:57 pm

Hi shentongascu,

Seems like I haven't been paying much attention to this site for the last few days. An alarm is part of the OS. A timer by contrast is part of an application. An alarm will not be destroyed simply because the OS is low on memory. A timer might be. Alarms are destroyed by a power down but as you say, that can be dealt with. A good thing about alarms is they can be set up for times in the future (rather easily) and you can "set'em and forget'em" sort of.

You've probably had to make something by now. Hope this helps anyway.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests