Even if you’ve got a brilliant idea for an app and develop a unique design, you won’t get far in the market if you fail to optimize its performance. Apps that eat up battery life, have slow interfaces or require lots of working memory are simply bound to get negative reviews. If you’re planning to build an Android app, have a look at our 5 essential tips to avoid these issues and create a fun, lightweight and agile app.

1. USE CURSORLOADER OBJECTS

The idea here is to off-load long-running operations from the user interface (UI) thread. This is how you’ll be able to avoid the annoying “Application Not Responding” (ANR) dialog. You can boost the speed of displaying data on your app by using CursorLoader objects, thanks to which users can still interact with the app even while a query is being processed in the background. Add this object to your app and it will initiate a separate background thread for every ContentProvider query, returning results to Activity that was the origin of the query only after it’s finished.

2. MAKE IT LIGHT ON BATTERY LIFE

Battery-draining apps never succeed on the market. Some of the most important factors that affect battery life are regular wake-ups for updates, regex without JIT, textual data parsing, and data transfer via EDGE and 3G.

When designing the wakelocks for your app, make sure to set the lowest possible level. Enable android:keepScreenOn as well. When possible, use coarse network location instead of GPS. In fact, you should also unregister – GPS location updates might be still going on after onPause().

3. CONSIDER NETWORK CONNECTIVITY

Another key area of interest is network connectivity. It’s a good idea to build your app so its skips operations when there’s no connection. Set it up to update only if 3G or WiFi connections are available and not in roaming

A different way to optimize the performance of your app relevant to network connectivity is choosing a relatively compact data format. Binary formats which combine text and binary data into one request are your best pick.

4. SHIFT LONG-RUNNING TASKS TO BACKGROUND

As mentioned before, expect all your operations by default running on the main thread (the UI thread) of your app. Since this thread is in the foreground, it has an impact on the responsiveness and efficiency of your app. And you don’t want users to deal with freezes or system errors, do you?

To optimize your app’s responsiveness, shift long-running tasks like complex calculations or database operations from the main thread to a separate background thread with AsyncTask class or IntentService as your tools for organizing this background work.

Make sure to create a background worker thread or establish a Thread or HandlerThread class for this purpose. Remember to specify the property for the thread to be in the background – otherwise, it will affect the performance of your app because the default thread priority is always the UI thread.

5. THINK TWICE ABOUT YOUR LAYOUT

User interface is the final factor you should take into account when optimizing your app. Developers need to closely collaborate with layout managers on this one – if they stick only to the basic features set out by designers, they risk creating apps that abuse memory and cause annoying lags in the UI.

One way to deal with this problem is to have a close look at your app to spot potential layout performance issues with the use of the Hierarchy Viewer tool – it’s included in Android SDK. Try Lint as well – it will scan your application sources in search for bugs and check your hierarchy optimization as well.


Follow these tips and you’ll be on your way to building a perfectly optimized Android app with a smooth UI that will give full credit to your mind-blowing app idea.


Ready to create your own mobile app? Fill in this form to get a free quote for your app idea.