سؤال

I have an app that connects to an external sensor through blue tooth. The sensor is for an ECG and is constantly sending data. I need the phone to sleep without severing this blue tooth connection how can i do that?

Basically i just want to save as much power as possible while the phone and sensor are performing an ECG. The connection may need to remain open for 8 or more hours.

هل كانت مفيدة؟

المحلول

You should use Service class, this class is intented to do long task not linked to any activity life cycle, Service has its own life cycle, and you definitely must use it if you want a long task to remain active even when non of your activities is actually visible, please refer to: http://developer.android.com/reference/android/app/Service.html for more information about services. This is one of the main building components in android and a good understanding of them is a MUST...

Hope this helps.

Regards!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top