September 15, 2011

Android Optimization Tips #1

It's easy to write code that does required function. But writing efficient code requires attention to few things that increase app's performance and use erexperince.


1. Don't hangup UI thread, do heavy things on separate thread. Use AsycTask or Runnable.

2. If your app makes HTTP calls when app is in background and not visible to user

* App should make HTTP calls only if Internet is available else it should stop doing so and should start doing it again when Internet connectivity is available.

 ** This will improve battery life **

3. Release all, database Cursor, Context, i/o streams or file streams When are done with it, or do it when user press Back key or destroy() lifecycle method.

4. Use only permissions which is required by application, remove unnecessary ones from AndroidManifest.xml * unnecessary use of permission gives user a wrong signal about your app, potential spam or malicious software. Be wise and review permission used by app.

5. Decide, your app should work in background when user's battery is critically low?
* if an application fetches location updates at every 5mints in background, then it eats of decent amount of power. In such cases you should check if battery level is below 30% or so it should stop doing it.

Example, phones built in Camera App, which doesn't work/open when battery level is low.

Make app smarter, and save phone's power!

** Take Care of User's Battery, specially its below certain levels **

Leave your comments and suggestions on article.