Pages

Wednesday, March 6, 2013

Small Introduction to Android Optimization

Hi guys,

In the next couple of months I'll be writing my thesis on "Optimizing Android Apps: Tips for better usability, performance and battery life". Since I'll probably will be discussing a lot of different topics, I'll be posting some of my ideas and experiences here. First of all because I wouldn't want to keep you from using this information for better development, but mostly because I'm very much interested in the comments of other developers. My thesis will be written in Dutch but I'll translate the topics to English for this blog.

Why, where and when?

When I started looking for information on the web, I saw a lot of presentations on this subject. After watching them all, I realized all of them start with global view about Android and what makes one app better than another. The way I see it, you can ask yourself three simple questions: Why, where and when?

Why should we spend time optimizing our apps? They work fine, all of the requested features are implemented. The device is able to do what it should do. Well actually, this is great. Especially if you have developed an app that does something no other app can do. Unfortunately, this is usually not the case.
By now, there are probably around 750.000 apps for Android available. The chances of creating a completely new app are rather small. So there is definitely a lot of competition. 

The thing that developers want is for their app to be downloaded, a lot. It's your task to make sure that your app is better than those other 10 that do exactly the same thing.
The thing that the user wants is to be able to do something with a certain application without wasting time. This 'wasting time' can happen on different levels, whether it's waiting for something to process, having to run through a lot of different screens before reaching the right one or even having to recharge the phone because its battery is draining really fast. As exemplary developers, it is our duty to give the user the best possible experience when using an Android app.

Getting featured

There is one thing almost all Android developers have in common. They all want their app to get featured. Once an app gets featured on Google Play, it can easily be downloaded 10 times as much in only a day. The problem is, there are only a small number of apps that get featured. The bar is set pretty high but the bigger the effort, the bigger the reward.

Now we know why we should spend time for optimization, it's important to know where you should be optimizing. First of all, mobile devices are in many ways different from PC's, but the most important difference is their limited resources such as battery life, data traffic, memory and storage

For the device to work properly, we should make sure our apps respect these limitations. Many devices, especially low-end devices, can take a lot more time for processing data. If we make sure that our app doesn't use unnecessary memory, we can easily speed this up.
We have also have to keep this principle in mind when we are getting data from the network. Most users have a limited data plan on their mobile phones and they don't want to pay anything extra at the end of the month.

But if you ask me, the most important issue of mobile phones is battery life. Every user expects their device to make it through the day without have to plug it in. This has always been a problem with smartphones so it's our job, as exemplary developers, to keep the battery from draining too fast. I will probably be focusing on this topic the most.

Having said that, there is only one question that remains. When should I optimize my application?
"Premature optimization is the root of all evil" - Donald Knuth
Now what do I mean by that? Simple, only start thinking about optimizing when your application does what it has to do. If you don't you'll start to lose way too much time on optimizing some process that doesn't really need to be optimized.

Use tools. Android provides a number of tools that you can use to check where your app needs optimization, but in order to use it, you have to be able to test your code.


That's all for now, guys. Starting next week, I'll be posting my first, more practical, tips on Android optimization. Thanks for reading and be sure to check out my other posts on Google Maps API v2.

Stay tuned for more!

No comments:

Post a Comment