Skip to content
michael edited this page Nov 9, 2015 · 3 revisions

Manage the event queue.

Usage Notes:

EventFacade APIs interact with the Event Queue (a data buffer containing up to 1024 event entries).Events are automatically entered into the Event Queue following API calls such as startSensing() and startLocating(). The Event Facade provides control over how events are entered into (and removed from) the Event Queue. The Event Queue provides a useful means of recording background events (such as sensor data) when the phone is busy with foreground activities.


eventClearBuffer Clears all events from the event buffer.
Example (python): droid.eventClearBuffer()
eventGetBrodcastCategories Lists all the broadcast signals we are listening for
eventPoll Returns and removes the oldest n events (i.e. location or sensor update, etc.) from the event buffer.
number_of_events (Integer) (default=1)
returns: (List) A List of Maps of event properties.
Actual data returned in the map will depend on the type of event.
 Example (python):
     import android, time
     droid = android.Android()
     droid.startSensing()
     time.sleep(1)
     droid.eventClearBuffer()
     time.sleep(1)
     e = eventPoll(1).result
     event_entry_number = 0
     x = e[event_entry_ number]['data']['xforce']
 

e has the format:
[{u'data': {u'accuracy': 0, u'pitch': -0.48766891956329345, u'xmag': -5.6875, u'azimuth': 0.3312483489513397, u'zforce': 8.3492730000000002, u'yforce': 4.5628165999999997, u'time': 1297072704.813, u'ymag': -11.125, u'zmag': -42.375, u'roll': -0.059393649548292161, u'xforce': 0.42223078000000003}, u'name': u'sensors', u'time': 1297072704813000L}]
x has the string value of the x force data (0.42223078000000003) at the time of the event entry.

eventPost Post an event to the event queue.
name (String) Name of event
data (String) Data contained in event.
enqueue (Boolean) Set to False if you don\'t want your events to be added to the event queue, just dispatched. (optional) (default=false)
 Example:
   import android
   from datetime import datetime
   droid = android.Android()
   t = datetime.now()
   droid.eventPost('Some Event', t)
 
eventRegisterForBroadcast Registers a listener for a new broadcast signal
category (String)
enqueue (Boolean) Should this events be added to the event queue or only dispatched (default=true)
Registers a listener for a new broadcast signal
eventUnregisterForBroadcast Stop listening for a broadcast signal
category (String)
eventWait Blocks until an event occurs. The returned event is removed from the buffer.
timeout (Integer) the maximum time to wait (optional)
returns: (Event) Map of event properties.
eventWaitFor Blocks until an event with the supplied name occurs. The returned event is not removed from the buffer.
eventName (String)
timeout (Integer) the maximum time to wait (in ms) (optional)
returns: (Event) Map of event properties.
receiveEvent Returns and removes the oldest event (i.e. location or sensor update, etc.) from the event buffer.
returns: (Event) Map of event properties.
Deprecated in r4. Use eventPoll instead.
rpcPostEvent Post an event to the event queue.
name (String)
data (String)
Deprecated in r4. Use eventPost instead.
startEventDispatcher Opens up a socket where you can read for events posted
port (Integer) Port to use (optional) (default=0)
stopEventDispatcher Stops the event server, you can\'t read in the port anymore
waitForEvent Blocks until an event with the supplied name occurs. The returned event is not removed from the buffer.
eventName (String)
timeout (Integer) the maximum time to wait (optional)
returns: (Event) Map of event properties.
Deprecated in r4. Use eventWaitFor instead.
Clone this wiki locally