Monitoring Android Events
Aug 31, 2010, 18:35 (0 Talkback[s])
(Other stories by Frank Ableson)
"What if some of those buttons are only supposed to be available
under specific device conditions? Examples include providing a
button only when a connection to a remote Bluetooth peripheral has
been established or some other specific device condition.
"Or let's say your device is going to be used to compute pi to
the … some really high precision value that is likely to take
a lot of computational cycles. You might not want to perform that
calculation if your device is not connected to power in the
interest of battery life.
"Or you may only want your device's special features to be
enabled when the device is "docked".
"The "easy solution" is to check, or poll, for this condition
periodically in addition to checking at application start-up or
even based on various user interaction. While this approach will
generally work, the preferred approach is to let our applications
be "event-driven". Then the user interface may be updated as soon
as the condition changes — without the reliance upon some
sort of user interaction, or costly polling"