Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

5 tips to improve performance in Android applications

, 25 Feb 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
If your application has many time-intensive operations, here are some tricks to improve the performance and provide a better experience for your users. 1) Operations that can take a long time should run on their own thread and not in the main UI thread. If an operation takes too long while it runs o

If your application has many time-intensive operations, here are some tricks to improve the performance and provide a better experience for your users.

1) Operations that can take a long time should run on their own thread and not in the main UI thread. If an operation takes too long while it runs on the main thread, the Android OS may show an Application not responding (AND) dialog, offering an option for the user to close your application.

Web services calls are especially sensitive to slowdown due to network problems, you don’t want to depend on the processing speed of an external provider. I’ve also taken advantages of threads to precalculate graphics that are displayed later on on the main thread.

2) Cache values from web service calls that will not change often in a local database, especially if the data is long to get. A call to the database is faster than a call to an external service, will not use data for your users and will work even it the device is offline. You should timestamp this cache to refresh the data at regular intervals.

Cache web service calls, especially if the user will rotate the screen or switch applications often. You can timestamp this cache if you want to avoid keeping data that’s too old for you.

3) Avoid trying to call external resources again and again if the wifi and cellular networks are not available by checking their state from time to time. If you never check and your applications requires many external calls, you will waste a lot of time preparing requests that are sure to fail and waiting for the connection timeout.

4) Save the state of your activities on the on(&). Keep the state of the activity, if the user switches application

If there are other bottlenecks in your application, but you are not sure where they are, you should profile your application. Take a look on my article on profiling Android applications.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Cindy Potvin

Canada Canada
No Biography provided
Follow on   Twitter   Google+

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 26 Feb 2014
Article Copyright 2014 by Cindy Potvin
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid