Skip to Content
Pro Android Apps Performance Optimization
book

Pro Android Apps Performance Optimization

by Hervé Guihot
January 2012
Intermediate to advanced
282 pages
7h 4m
English
Apress
Content preview from Pro Android Apps Performance Optimization

Activity Lifecycle

The threads you create are not automatically aware of the changes in your activity's lifecycle. For example, a thread you spawned would not automatically be notified that your activity's onStop() method has been called, and the activity is not visible anymore, or that your activity's onDestroy() method has been called. This means you may need to do additional work to synchronize your threads with your application's lifecycle. Listing 5–20 shows a simply example of an AsyncTask still running even after the activity has been destroyed.

Listing 5–20. Computing a Fibonacci Number In the Background Thread and Updating the User Interface Accordingly

public class MyActivity extends Activity {     private TextView mResultTextView; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Android High Performance Programming

Android High Performance Programming

Enrique López Mañas, Diego Grancini
Pro Android Graphics

Pro Android Graphics

Wallace Jackson

Publisher Resources

ISBN: 9781430239994Purchase book