News

News Feeds

Google details Android 4.4 KitKat, its latest mobile upgrade
Google adds Android Device Manager app to the Play Store's virtual shelves
New Shooting Games
Skype updated on Android, includes handy picture-in-picture option
Chrome beta update introduces a more responsive mobile browser
Official BBC Sport App Now Supports iPad & Android-Powered Tablets
Next year you'll be able to create your own games for Android with Createrria
Oracle trying to appeal old lawsuit, still claims Google infringed to create Android
Apps of the Week
Google News updates mobile web app with real time updates, new design
Google set to launch set-top box in 2014 with Nexus branding
Android 4.4 KitKat now on 1.1 percent of Android devices: Google
Google Launches Redesigned Field Trip App to Google Play
Read this: Esquire's 'What you're not supposed to do' with Google Glass
Amazon Appstore renovated with new-look UI
Google Play update highlights tablet-optimized apps
Battlefield 4 Commander now available for Android, free on Google Play (and buggy)
BBM update for Android, iOS brings new features, iPad and iPod touch support
Best Android apps
Google Android 4.4 'Kitkat': seven things you need to know
Best Android apps
Buffer, a cross-network posting service that also does Google+, is hacked
Motorola Spotlight Player app now live in Google Play for Moto X devices
YouTube for Android 5.2.27 available for download, offline video playback not yet enabled
How To Bypass The BBM Waiting List On Android & iOS
Google's FlexyCore purchase could mean a smoother Android for the future
BBM for Android and iPhone is here
Create your own font in Android: There's an app for that!
Google Play "Newsstand" discovered in version 4.4 teardown
Google tops $1,000 per share: The Mountain View juggernaught keeps growing
Google Play Store update bringing new "Designed for Tablets" section on November 21st
Tapatalk now free, HD version renamed 'Pro' with additional features
Top Android launcher applications
Recommended Application
Google Play experiencing issues for most everyone
The Latest TeamViewer For Android Update Adds Clipboard Synchronization, Sound Options, And More
Google Drive 1.2.352.10 Update Finally Rolling Out Features Pull-to-Refresh, Easier Uploads, Tweaked UI
Google launches Android game vending machines in Japan
Gmail app for Android to soon display ads: Report
Cleaner conversation view, improved multi-select and more for Gmail on Android
Android Studio 0.2.9 Released
Useful Android App : Todoist: To Do List, Task List
Android's Applications
64-bit processors and 4GB of memory coming in 2014
eBay adds location-relevant search results, NFC item sharing
Kit Kat 4.4 – The future of confectionery has arrived
Android has over one billion activations!
Android passes 1 billion activations
Amazon Is Giving Away 11 Of The Best Android Apps Right Now
US warns government employees over Android malware risks
Updated YouTube app for Android and iOS official with video multitasking, new look and more...
Hangouts gets an update, adds more butter and more emojis
Android nearing one billionth activation
Sync an Android in an Exchange Land
Google Play Games: Everything you need to know
Goodbye Google+ Messenger, hello G+ Photos
Apps of the Week
Get ready for college with textbooks on Google Play
Jellybean finally knocks Gingerbread off top spot
Getting the most out of Google Now voice actions

Android Application Development: 10 Tips for More Efficient Apps

The best recipe for becoming a complete flop in Google Play is to release an app that is battery and memory hungry with a slow interface. Most likely, these qualities will ensure negative reviews from users and result in a bad reputation, even if your app has great design and a unique idea.

Every drawback in product efficiency, battery and memory consumption can really affect your app's success. That's why it is critical to develop well-optimized, smooth running apps that never make Android system guard against them. We will not speak about efficient coding, since it goes without saying that the code you write should stand any performance test. But even brilliant code takes time to run. In today's post, we'll talk about how to minimize this time and make apps that users love.

Efficient threading

Tip 1. How to off-load operations onto threads in background

Since by default all operations in an app run on the main thread (UI thread) in the foreground, the app responsiveness might be affected, which will imminently result in hangs, freezes and even system errors.

To reinforce responsiveness, you should shift long-running tasks (e.g. network or database operations, complex calculations) from an app's main thread to a separate background thread. The most effective way to accomplish this task is at a class level. You can use AsyncTask class or IntentService class to organize background work. Once you have implemented an IntentService, it starts when needed and handles requests (Intents) using a worker thread.

When using IntentService, you should consider the following limitations:

This class does not put results to UI, so to show results to users use Activity.

Only one request is processed at a time.

Any request processing can not be interrupted.

Tip 2. How to avoid ANR and stay responsive

The same approach of off-loading long-running operations from the UI thread will save your users from the "Application Not Responding" (ANR) dialog. What you need to do is to create a background worker thread by extending AsyncTask and implementing doInBackground() method.

Another option is to create a Thread or HandlerThread class of your own. Keep in mind that unless you specify "background" priority for the thread, it will slow down the app since the default thread priority is the same as of the UI thread.

Tip 3. How to initiate queries on separate threads

Displaying data is not immediate, although you can fasten it by using CursorLoader objects, which allows not to distract Activity from interacting with a user while query is processing in the background.

Armed with this object your app would initiate a separate background thread for each ContentProvider query and return results to Activity from which the query was called only when the query is finished.

Tip 4. What else you can do

Use StrictMode to detect potentially lengthy operations you do in the UI thread.

Use special tools, i.g. Systrace, Traceview, to find bottlenecks in your app responsiveness.

Show progress to us

ers with a progress bar.

Display splash screens if initial setup is time-consuming.

Device battery life optimization

We cannot blame users for angrily uninstalling applications that abuse battery life. The main threats to battery life are:

Regular wake-ups for updates

Data transfer via EDGE and 3G

Textual data parsing, regex without JIT

Tip 5. How to optimize networking issues

Make your app skip operations if there is no connection; update only if 3G or WiFi is connected and there is no roaming.

Choose compact data format, e.g. binary formats that combine text and binary data into one request.

Use efficient parser; consider choosing stream parsers over tree parsers. For faster UX lessen round-trip times to server.

When possible use framework GZIP libs for text data to make the best use of CPU resources.

Tip 6. How to optimize apps working in foreground

When designing wakelocks, set the lowest level possible.

To avoid battery costs caused by potential bugs you might have missed, use specific timeouts.

Enable android:keepScreenOn.

In addition to GC (garbage collection) consider recycling Java objects manually, e.g. XmlPullParserFactory and BitmapFactory; Matcher.reset(newString) for regex; StringBuilder.setLength(0).

Mind synchronization issues, although it can be safe when driven by UI thread.

Recycling strategies are used heavily in ListView.

Use coarse network location not GPS when possible. Just compare 1mAh for GPS (25 sec. * 140mA) and 0.1mAh for network (2 seconds * 180mA).

Make sure to unregister as GPS location updates can continue even after onPause(). When all applications unregister, users can enable GPS in Settings without blowing the battery budget.

Since the calculation of a floating point requires lots of battery power, you might consider using microdegrees for bulk geo math and caching values when performing DPI tasks with DisplayMetrics.

Tip 7. How to optimize apps working in background

Since each process requires 2MB and might be restarted when foreground apps need memory, make sure the services are short-lived.

Keep memory usage low.

Design app to update every 30 minutes but only if device is already awake. Services that pall or sleep are bad, that is why you should use AlarmManager or manifest elements: stopSelf() when finished. When you start service using AlarmManager, apply the *_WAKEUP flags with caution. Let Android bin your application update together with the rest through setInexactRepeating(). When using , enable/disable its components in manifest dynamically, especially when no-ops.

Tip 8. What else you can do

Check current states of battery and network before launching a full update; wait for better states for bulk transfers.

Provide users with battery usage options, e.g. update intervals and background behavior.

Implementing UI that leaves minimum memory footprints

Tip 9. How to identify layout performance problems

When creating UI sticking solely to basic features of layout managers, you risk to create memory abusing apps with annoying delays in the UI. The first step to implementation of a smooth, memory caring UI is to search your application for potential layout performance bottlenecks with Hierarchy Viewer tool included into Android SDK: /tools/.

Another great tool for discovering performance issues is Lint. It scans application sources for possible bugs along with view hierarchy optimizations.

Tip 10. How to fix them

If layout performance results reveal certain drawbacks, you might consider to flatten the layout by converting it from LinearLayout class to RelativeLayout class, lowing level hierarchy.