Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would rather run your code as a Service, and hook it to the Activity having the UI through <a href="http://developer.android.com/reference/android/content/Context.html#bindService%28android.content.Intent,%20android.content.ServiceConnection,%20int%29" rel="nofollow"><strong>bindService</strong></a>.</p> <p>The other option you have, is to create a <a href="http://developer.android.com/reference/android/os/PowerManager.html" rel="nofollow"><strong>WakeLock</strong></a> and maintain the phone on all the time. It may be very hard to the battery, though.</p> <p>Check the dev guide entry for bound services and see if it fits your design: <a href="http://developer.android.com/guide/topics/fundamentals/bound-services.html" rel="nofollow">http://developer.android.com/guide/topics/fundamentals/bound-services.html</a></p> <p>There are many very good tutorials out there for running services, with varying degrees of complexity. Take a look at some of them here:</p> <ul> <li><a href="http://www.vogella.de/articles/AndroidServices/article.html" rel="nofollow">http://www.vogella.de/articles/AndroidServices/article.html</a></li> <li><a href="http://marakana.com/forums/android/examples/60.html" rel="nofollow">http://marakana.com/forums/android/examples/60.html</a></li> <li><a href="http://developerlife.com/tutorials/?p=356" rel="nofollow">http://developerlife.com/tutorials/?p=356</a></li> <li><a href="http://mylifewithandroid.blogspot.com/2008/02/double-life-of-service.html" rel="nofollow">http://mylifewithandroid.blogspot.com/2008/02/double-life-of-service.html</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload