Android: Optimizing Apps in your hands? — Part 2
Minimize the Application Size
Mobile phones aren’t powerful GPUs, yet! Also, do you know that most of the Android market share is consumed by low-end configuration mobile phones? Some of them don’t even support 2G or 3G, even downloading your huge application in a moment need would be a nightmare for the app’s users. The less your app consumes space on such constrained phones, the better.
Effective API design
The way an API has been designed has a huge impact on how it impacts the app’s performances. An incomplete or lazily designed API can be a burden on the mobile application. Workarounds on APIs usually put too much pressure on the network limitations.When designing the API payloads of your mobile app ensure that you have:
- Consistency: The developer should know that expect, leaving no space for least astonishment.
- Completeness: Having reduced workarounds
Starting from UI and going all the way to data can be one great way to design a consistent and complete API payload that improves your app’s performance. Just because you can send, don’t send everything from mobile to your API. Only send what’s required.
Cache Data to Optimize for Offline Mode
When your network is weak, display whatever data you have, while fetching required data. Doing so will:
- Reduce your server load
- Reduce the number of your mobile phone’s radio usage, improving your app’s battery life
If you don’t have a testing team at your disposal, try switching your phone into the airplane mode and test your app for offline performance.
Optimizing Screen Size for High Mobile App Performance
A lot has been spoken about the screen sizes, Android raises some really big concerns here as there are literally thousands of devices, each with their own resolution and screen size.
As a rule of thumb:
- Build for small and medium screens
- Optimize for MDPI and HDPI
- Implement adaptive UI flows
Don’t have a 100’s of devices to test the screen size and resolution? Test with emulator configurations.
Memory Usage in Android
In order to provide mobile users with the ability to multitask, Android sets limits to how much RAM is available to an application. These limits are not static and change as mobile usage increases or decreases.
Considering RAM limitations throughout app development, and apps that are running in the background can hog unnecessary resources.
But, you can optimize your app by:
- Limiting the lifespan of services, consider using intent service to limit the lifespan
- Release UI resources when users move to a different UI
- Utilize memory efficient code constructs
- Minimize the use of external libraries
How Fast does your App Launches?
Do you know that for the average top 25 apps on PlayStore, the launch time goes anywhere from 800ms to 4.5s? Now, 4.5s is way too much for most use cases.
Bottom line, apps need to start quickly!
- Instantiation of many views
- Expensive content like decoding bitmaps
- Running layouts
To make your app launch faster on Android:
- Don’t inflate parts of UI that you don’t require on the first launch. Use placeholder for hierarchies that can be optionally inflated later
- Avoid memory churns due to allocation and garbage collections whenever possible
- Use tools like Apteligent to monitor and optimize your app launch time
- Avoid initialization code in your app’s object
- Remember, an app that has been launched recently, and an app that is launching for the first time will behave differently
Restoring User Data on New Devices
App users often spend a lot of time setting up the application and make it work as they intend to on their phones. When they re-install an app, then most users expect their old settings to re-surface.
Preserving settings data can help enhance the quality of your application by:
- Any setting modified by the user
- Push notification settings
- Whether the user has seen the welcome screens and introductory onboarding screens
Find Latency Killers
It is very important to remove latency issues from your application. Latency is known to cause app errors and often crashes the entire application. Statistics have told us that if an app runs slowly, more than 50% users will uninstall your app within 24 hours.
To effectively deal with latency related issues:
- You can restrict third-party latency sources when your network quality is poor
- Reduce the need for latency killer APIs that you might be using on your mobile