[android-developers] Service or Thread for accelerometer monitoring?
Hello, I am stuck with making a decision and I could use some expert help. I have a need to monitor motion, either with the compass or accelerometer to ensure that someone is safe. I have code which works really well when using the accelerometer, BUT it can suck a battery flat in around 30 minutes. To help mitigate this i am considering a 'duty-cycle- of 1 minute on, and 1 minute off - so should straight away be on to a 50% increase in battery life, and later I'll refine this. Im developing for api 7 (2.1 eclair) and while I have some programming experience, i need guidance on which route to follow to enable the duty-cycle usage of the accelerometer. One avenue of research indicates that using threads is the way to go - however since threads can be killed off with the main UI (screen goes to sleep, etc), so i'm leaning towards using a service which can I can START_STICKY. Which route do you recommend? Thread or Service? Regards, Fred -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Service or Thread for accelerometer monitoring?
Thread or service is not generally a decision -- they are two different things, for different purposes. A thread lets you do work off of the main UI thread. A service lets you tell the system to try to keep your process around instead of killing it in the background. On Mon, Aug 1, 2011 at 2:08 PM, Fred Niggle fred.nig...@googlemail.comwrote: Hello, I am stuck with making a decision and I could use some expert help. I have a need to monitor motion, either with the compass or accelerometer to ensure that someone is safe. I have code which works really well when using the accelerometer, BUT it can suck a battery flat in around 30 minutes. To help mitigate this i am considering a 'duty-cycle- of 1 minute on, and 1 minute off - so should straight away be on to a 50% increase in battery life, and later I'll refine this. Im developing for api 7 (2.1 eclair) and while I have some programming experience, i need guidance on which route to follow to enable the duty-cycle usage of the accelerometer. One avenue of research indicates that using threads is the way to go - however since threads can be killed off with the main UI (screen goes to sleep, etc), so i'm leaning towards using a service which can I can START_STICKY. Which route do you recommend? Thread or Service? Regards, Fred -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Service or Thread for accelerometer monitoring?
Thank you for your reply, It appeared to be a decision because I was without the facts. Now I am informed I can now continue. Best Regards, Fred On 01/08/2011, Dianne Hackborn hack...@android.com wrote: Thread or service is not generally a decision -- they are two different things, for different purposes. A thread lets you do work off of the main UI thread. A service lets you tell the system to try to keep your process around instead of killing it in the background. On Mon, Aug 1, 2011 at 2:08 PM, Fred Niggle fred.nig...@googlemail.comwrote: Hello, I am stuck with making a decision and I could use some expert help. I have a need to monitor motion, either with the compass or accelerometer to ensure that someone is safe. I have code which works really well when using the accelerometer, BUT it can suck a battery flat in around 30 minutes. To help mitigate this i am considering a 'duty-cycle- of 1 minute on, and 1 minute off - so should straight away be on to a 50% increase in battery life, and later I'll refine this. Im developing for api 7 (2.1 eclair) and while I have some programming experience, i need guidance on which route to follow to enable the duty-cycle usage of the accelerometer. One avenue of research indicates that using threads is the way to go - however since threads can be killed off with the main UI (screen goes to sleep, etc), so i'm leaning towards using a service which can I can START_STICKY. Which route do you recommend? Thread or Service? Regards, Fred -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en