Yes the only way to do it hold a wake lock.  Someone needs to keep running
to monitor the stream of data from the sensor to determine if it looks like
it is shaking.  The NDK won't help you in any way here, unless your code for
computing whether there is a shake from the data stream can run
significantly faster as native code and thus use less CPU.

The current accelerometers don't have a "detect shake" thing inside of
themselves, nor is there any facility or API for the platform to be woken up
by it and tell the application, if it did.

On Thu, Sep 10, 2009 at 2:29 PM, Bart van Wissen <[email protected]>wrote:

>
> I would like to detect shake movement in a service that is running in
> the background, even when the phone is not currently being used.
> Is it true that the only way to do this is to hold a wake lock? I
> suppose this would consume a lot of energy and drain the battery very
> fast.
>
> Is there no way to wake up the phone whenever a shake movement occurs?
> Maybe with the native sdk? I would imagine the accelerometer causing
> some kind of interrupt.
>
> Any ideas?
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to