Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android High Performance - Droidcon VN 2017

Android High Performance - Droidcon VN 2017

Android High Performance - Droidcon VN 2017

Enrique López Mañas

May 16, 2017
Tweet

More Decks by Enrique López Mañas

Other Decks in Programming

Transcript

  1. But what is high performance? • Strategies to create efficient

    software Layout Energy and battery Security Multithreading Programming patterns Debugging techniques
  2. ANR • No response for input event in 5 seconds

    • BroadCast receiver still executing after 10 seconds
  3. Memory - Enumerations Summary • Unnecessary allocations • AVOID USING

    THEM • Change as much as possible with static final integer values
  4. Memory - Constants Constants in the code should be static

    and final to take advantage of memory savings and to avoid initialization in Java compiler
  5. Memory Leaks “a memory leak is a type of resource

    leak that occurs when a computer program incorrectly manages memory allocations in such a way that memory which is no longer needed is not released.” Wikipedia
  6. Threading “is the smallest sequence of programmed instructions that can

    be managed independently by a scheduler” Wikipedia
  7. Threading - AsyncTask Communicate Worker Thread with UI Does not

    need to communicate UI? Does not need to notify user? DOES NOT NEED ASYNCTASK! If the AsyncTask has all parameters Void, you are only implementing doInBackground() and you do not need an AsyncTask
  8. Threading - AsyncTaskLoader Use it to fetch data Same features

    as AsyncTask… …plus the Activity life-cycle independency and data caching
  9. Threading - Services • Not threads! • Executed in UI

    Thread by default • Never start a long running operation! • Lifecycle
  10. Threading - IntentService • Particular implementation of a Service •

    Execute sequential operations in background • Don’t need to handle the lifecycle
  11. Networking - best practices Pre-fetch • Download as much as

    possible • (specially if idle connection)