Optimizing Java code for Android

Keyboard Shortcuts

There are many practices you can follow to improve an Android app's performance and memory usage. These techniques are sometimes called "micro-optimization", since each change might only result in a very small amount of improvement. Before optimizing your app you should measure its current performance, so you can find out after optimization what benefits you've achieved.

- [Voiceover] Java developers are used to…optimizing their code for particular platforms.…The coding techniques that work for one platform…might not be the best for another platform.…Optimizing your code can help improve…the performance and memory usage of your app.…Now you might not need to optimize,…and in fact, many developers feel…that you should only do these optimizations…if you detect that there are problems with your app.…These are sometimes called micro-optimiziations.…

In some environments making the kinds of code changes…I'm going to describe here…might not result in observable improvement,…but if your app is having performance issues,…these are some of the things you can look at…to improve the situation.…All of the suggestions I'm going to make…can be summarized in a couple of recommendations.…Don't do work that you don't need to do…and don't allocate memory if you can avoid it.…All of these optimization suggestions…are driven by the reality that a mobile device doesn't have…the same amount of memory or processing power that,…

Resume Transcript Auto-Scroll

Author

Updated

8/24/2017

Released

3/18/2016

Programming Android apps with Java? Take your skills to the next level with some of the most popular design patterns and APIs for the Android SDK. David Gassner explains how to call and implement callback methods, save instance states and global data, and wrap asynchronous tasks to create a smooth user experience during app configuration changes. Plus, learn how to use Java packages (APIs) to store data, read text, display graphics, play audio, and work with information from device sensors like the accelerometer.