python748 / alternate-java-bridge-library

Automatically exported from code.google.com/p/alternate-java-bridge-library
Apache License 2.0
0 stars 0 forks source link

Add a "time of day" component with an event trigger #61

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The feature I am looking for is a component that allows you to set itself equal 
to a time of day, say noon.  With the component in the system and set to a 
specific time, when that time is hit (checked against current system time), an 
event would trigger.  This would allow you to run code at a specific time.

This is useful for a number of things (usually service things), the simplest 
example would be an alarm.  So you set an alarm for noon.  the event triggers, 
and then i notify the user, "Hey WAKE UP!".

Original issue reported on code.google.com by bric...@gmail.com on 23 May 2012 at 7:50

GoogleCodeExporter commented 8 years ago
Added AlarmScheduler nonvisible component.

The alarm is handled through the android system. This means it has to open 
either a Form, or FormService. The form/formservice that gets opened by an 
alarm throws the "Alarm" event (the event is thrown by the Form/FormService 
itself).

Usage:
[In the Form which sets the alarm]
// Declare
private AlarmScheduler scheduler;

// Initialize in $define
scheduler = new AlarmScheduler(this);

// Set a new alarm for 5 seconds from now, and have it open AlarmForm
long timeToWake = System.currentTimeMillis() + 5000;
scheduler.addAlarm("Alarm1", timeToWake, AlarmForm.class, false);

The first argument is simply a name for the alarm. You can cancel an alarm, and 
to do so, you use this name to cancel it.

The second argument is the time in milliseconds for the alarm to go off.

The third argument is the form, or formservice to open when the alarm goes off.

The fourth is just a boolean telling the method if it's a Form, or FormService 
that needs to be opened.

I'll also be adding another method similar to this which will wake the screen 
if it has gone to sleep.

Original comment by IMPINC...@gmail.com on 25 May 2012 at 10:43

GoogleCodeExporter commented 8 years ago

Original comment by IMPINC...@gmail.com on 25 May 2012 at 10:43

GoogleCodeExporter commented 8 years ago
Does AlarmScheduler extend AlarmManager?

Original comment by bric...@gmail.com on 26 May 2012 at 2:33

GoogleCodeExporter commented 8 years ago
No. It uses AlarmManager, but doesn't extend it.

Original comment by IMPINC...@gmail.com on 26 May 2012 at 2:56

GoogleCodeExporter commented 8 years ago
Added addWakeAlarm method which works the same as the addAlarm method, only 
this will wake the screen up if it is asleep.

Original comment by IMPINC...@gmail.com on 26 May 2012 at 5:13

GoogleCodeExporter commented 8 years ago
This does not seem to be working properly...I mean it does if the application 
is running, by my understanding is that the Alarm Manager is meant to start the 
application if it is not running.  In attempting to implement this I have 
noticied it only works if the application is already running...

Original comment by bric...@gmail.com on 27 May 2012 at 8:07

GoogleCodeExporter commented 8 years ago

Original comment by IMPINC...@gmail.com on 8 Jun 2012 at 6:37