Building fast and responsive Android apps.

Lessons learnt while re-building the HopBucket Android App

Satyajeet Jadhav
HopBucket
5 min readApr 10, 2018

--

The days of the unpolished Android app are over. Over the years, Android has evolved into a beautiful and responsive system. So if users feel your app doesn’t live up to the rest of the Android eco system, they are going to ignore you. It is only fair to expect an application to be fast, responsive, and predictable.

If you are a new developer trying to take your app quality to the next level, this guide may help you.

While rewriting the HopBucket Android app, we had a simple goal in mind. We wanted our new app to be fast, responsive, and predictable! Here is a breakdown of the few techniques we employed to achieve our goal.

Content Delivery Network (CDN)

Simply put, CDN helps speed up the delivery of your content to your users. Though a CDN is not strictly a part of building an Android app, using one can improve the speed of your application dramatically. If your application relies on downloading a bunch of files, e.g. images, you should think about using a CDN service. For a detailed explanation on how to set it up read this AWS CDN guide.

Image Scaling

Image scaling simply means resizing your images. Image scaling lets you scale down images before the user sees them in the app. This lets you download only what you need. You don’t want to download a 5MB photo to display as a thumbnail. You’d rather download a 100px X 100px thumbnail. Image scaling let’s you resize a huge photo to a small thumbnail and everything in between.

There are two approaches to scaling images.

  1. As soon as the user uploads the original image, create and store scaled versions of this image.
  2. Scale and store images dynamically based on the parameters passed in the request to download the image.

HopBucket uses the second approach. Combine image scaling with CDN and you have a winning combo! Read more here.

Progressive Image Loading

It’s important that the images load fast in your app. This is one of the key factors which users rely on to determine the speed of your application. CDN and image scaling will already help you cover some ground here. But, more than images loading fast, it is important that the images ‘appear’ to load fast. Progressive image loading will help you out here.

Progressive Image Loading in action in the HopBucket Android app

HopBucket uses the Glide library to load and cache images. Here is how you can implement progressive image loading using Glide.

You can increase the intermediate steps for a smoother effect. e.g. 0.1x image, 0.3x image, 0.5x image, 0.7x image, and 1x image. But this might mean downloading almost double the number of bytes!

Persistence

Data persistence is a key technique in making an app feel fast and light.

The joy your users derive is inversely proportional to the number of times a loading indicator appears in your app.

Data persistence is the act of storing essential data to non volatile storage. This means some of the previously downloaded data is available even offline. Also, when the user comes back to the app, she sees a fully loaded page, instead of a blank page with a loading indicator.

In HopBucket, before fetching the feed, notifications, profile, etc. from the server, we show you the cached data. Better than showing the “loading…” screen! Once we have the data from the server, we update the views.

Prefetching

Prefetching is when you anticipate and send the requests to the server before the user asks you to do so. For this to be effective, you should be 100% sure about the requests you are going to make. e.g. fetching feed items at the login screen. You should not prefetch too aggressively as this could mean the difference between a well behaved app and an app that is a battery and data hog.

Animation

Animation helps make your application feel responsive to user actions like touch or zoom. It is important to use animations sparingly, though. We use animations for really simple stuff like scaling the like button up and down on touch.

Another simple animation we use is the waterfall animation when populating lists.

Waterfall Animation

Job Scheduling

This is perhaps the most important technique that will help you make your application fast and light and “performant”. Job scheduling can help you reduce your battery usage and improve your app’s performance.

A couple of use cases for job scheduling the HopBucket app

  1. Executing asynchronous network operations such as “liking a photo” — When a user clicks on the like button, you can give immediate feedback to the user by turning the like button red. Behind the scenes, you schedule the job that executes the API call. The network operation happens in its own time behind the scenes. The user doesn’t have to wait for it to complete! You can even schedule such jobs based on factors like network availability, wifi availability, device charging state, etc.
  2. Retrying failed requests — Network connectivity in real life is far too flaky compared to what a developer enjoys in her controlled environment. This means a user might lose connectivity in the middle of uploading photos. Job scheduling (coupled with persistence) can help you restart the upload when the user gets connected back again, automatically!

An excellent resource for getting started with job scheduling can be found here. There is also an excellent open source library — Android-job which abstracts out most of the complexities of job scheduling for you.

Conclusion

Building an Android app is a never ending activity. There will always be things that you can design and implement in order to improve the experience of your users. So it becomes important to pause a little and work on improving the small things that make up our app.

What I have described here are some of the methods that have drastically improved the user experience for HopBucket users. Please comment if you find this post useful and if you end up using any of the techniques above to improve your apps!

Thanks to Chetan Ashtivkar, Sanika Joshi, Ketan Ghatode, and Amol Khedkar for reading a draft of this post and for sharing their inputs.

HopBucket lets you share your travel experiences with the world in a fast and easy manner.

--

--