Post3

Don’t be a data hog! – Designing Android Applications

Posted by

There are tons of mobile apps out there in the market, each specializing in their own area. There are a plenty of apps built on a single idea, around the same concept. The question arises – how do we find the best application among them? Which one of these apps should you install? Usability, security, performance, user reviews & mobile data consumption etc. are some of the parameters that consumers use to judge the quality of an app. ‘Mobile data consumption’ is one factor that is often overlooked by mobile app developers and this in turn contributes to poorly designed mobile apps.
Today, most of the mobile phone apps we use, require internet connection. This means if consumers use the app in their mobile, they will have to spend mobile data on it. What if the mobile app you have installed is a ‘data hog’? It will eat away all your data without you even noticing it. The current situation is pathetic as there are a plenty of such apps we use on a daily.
Since we have developed the problem statement, the question now is, can something be done to reduce the data load on mobile apps? Can our apps be smart enough to process more and consume less data?

Here are the best practices that will help you design your app right:
As a developer we should focus on the following things –
Ask API developer to Design the API based on the usage of your app. i.e., you may ask your API developer to create a single API for a screen. Making multiple API calls to a single screen is a costly operation, therefore not advised.
Remove the unused information from the API response. Generally, it is observed that the data APIs contain more key / elements than actually being used in the app. This is a burden and should be eliminated.

For example:
{
“login”: “AndroidHitchhiking”,
“id”: 16745242,
“avatar_url”: “https://avatars.githubusercontent.com/u/16745242?v=3”,
“gravatar_id”: “”,
“url”: “https://api.github.com/users/AndroidHitchhiking”,
“html_url”: “https://github.com/AndroidHitchhiking”,
“followers_url”: “https://api.github.com/users/AndroidHitchhiking/followers”,
“following_url”: “https://api.github.com/users/AndroidHitchhiking/following{/other_user}”,
“gists_url”: “https://api.github.com/users/AndroidHitchhiking/gists{/gist_id}”,
“starred_url”: “https://api.github.com/users/AndroidHitchhiking/starred{/owner}{/repo}”,
“subscriptions_url”: “https://api.github.com/users/AndroidHitchhiking/subscriptions”,
“organizations_url”: “https://api.github.com/users/AndroidHitchhiking/orgs”,
“repos_url”: “https://api.github.com/users/AndroidHitchhiking/repos”,
“events_url”: “https://api.github.com/users/AndroidHitchhiking/events{/privacy}”,
“received_events_url”: “https://api.github.com/users/AndroidHitchhiking/received_events”,
“type”: “User”,
“site_admin”: false,
“name”: “Shadik Khan”,
“company”: null,
“blog”: null,
“location”: “New Delhi, India”,
“email”: “er.sadiqkhan@gmail.com”,
“hireable”: null,
“bio”: null,
“public_repos”: 9,
“public_gists”: 0,
“followers”: 1,
“following”: 1,
“created_at”: “2016-01-17T15:30:25Z”,
“updated_at”: “2016-12-30T12:01:24Z”
}

In the above response, information like created_at, updated_at, etc is all unwanted, so the API developer should remove all this information from the response.
Enable GZIP compression on your network request from both server side and client side. GZIP compresses the response and saves many a bytes to travel on network and consume mobile data.

MobileDataUsageImages

As shown in the figure, the GitHub API enabled GZIP and it saved 65% of data.
As an android developer if you are using HttpClient for network request then you have to write the code to enable the GZIP, but if you are using OkHttpClient (retrofit), it’s enabled by default.
Enable HTTP cache so when you make a request, it would cache the response locally and next time when you’re making the same request it would display data from cache.
Consider an application like GitHub when one can see the profile of a user, what if the viewer checks the same user profile 10 times in an hour? Profile related information of the user doesn’t change that frequently so it can be cached.
Here is how we enable caching in OkHttpClient?

private final OkHttpClient client;
public CacheResponse(File cacheDirectory) throws Exception {
int cacheSize = 10 * 1024 * 1024; // 10 MiB
Cache cache = new Cache(cacheDirectory, cacheSize);
client = new OkHttpClient.Builder()
.cache(cache)
.build();
}

For detailed description on OkHttpWiki.
Always display the updated data to user – At this point generally, every time the developer hits the API, it gives the same response as was for previous requests.

2

Showing updated data to user by making network request every time
So how can I show the updated data to user?
There are many ways to do this and one of them is push notification (Firebase Cloud Messaging). This will notify the user as and when there is any change in data on server side by sending a notification to the user device. Check the details about push notification integration at here.
You need to write the code that if there is any notification related to response (data) update on server, then you can call the API, get the updated data and display it to user. This way you don’t have to make network request until and unless you get the notification, so it will save the mobile data of user.

3

Give your user the option to choose as and when they want to sync data in background or when to play video automatically (when visible), like Twitter does it very well.
Also, you can provide the options like Image Quality, optional download/upload image or video on the basis of network type (mobile data, WiFi), just like WhatsApp does. It’s an extremely positive thing for an app, to give its users these options and let them decide what they want to do under these circumstances.
These sort of operations allow the users to have more control on their mobile data consumption, which puts a good impression on user.

4

These are few must have steps that would help you design a less data costly application and will gain great reviews by the consumers.

Related Posts

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *