Keep UI thread off screen

I am creating an application that updates the user interface using the runOnUiThread (Runnable) method. It is very important that this UI thread continues to work while the user launches this application, even when onPause (). However, I realized that when the screen is locked, Android stops the user interface flow; and I don’t blame them, perhaps to save battery power. But I want to know if there is a way to override this and say that the activity or system continues to work in the user interface thread.

+1
source share
1 answer

I would rather run your code as a Service and bind it to an Activity with a user interface via bindService ..

Another option that you have is to create a WakeLock and constantly maintain your phone. It can be very difficult for the battery.

Check out the dev manual entry for related services and see if it fits your design: http://developer.android.com/guide/topics/fundamentals/bound-services.html

There are many very good tutorials for running services with varying degrees of difficulty. Take a look at some of them here:

+5

All Articles