Android market share has been growing rapidly. With almost two dozen manufacturers developing Android devices, we’ve seen an explosion of different models – each with its own market differentiators and unique characteristics. Users now have choices, but these choices come at a cost. This proliferation of devices has led to what some developers call fragmentation and others call compatibility issues.
Terminology aside, it has become a challenging task to develop Android applications that support a broad range of devices. Developers must contend with different platform versions (Fig 1), devices with and without optional hardware like cameras and keyboards, and variations in screen sizes and resolutions (Fig 2). The list of device differentiators is lengthy, and grows with each new device.
While fragmentation makes the Android app developer’s life more complicated, it’s still possible to develop for and support a variety of devices – even all devices – within a single application. You just need the tools and the know-how to go about it.
This tutorial provides five techniques to help developers iron out compatibility wrinkles, including:
1. Providing alternate resources for different device configurations.
2. Specifying which platforms your application targets and supports.
3. How to change application behaviour based upon the platform version.
4. How to use optional load classes using Java Reflection.
5. Using Market filters to limit which devices use your applications.
While this tutorial won’t directly leverage any specific development tools, you will need a functioning Android development environment to develop applications. You may find it helpful to follow along through this tutorial using an existing Android application for reference. Feel free to use your own applications or one of the sample applications provided with the Android SDK for this tutorial.
Let’s begin with the most important thing you need to know about maximising application compatibility. It involves making assumptions, and you know what they say about making assumptions… In terms of designing for device compatibility, our best advice to you is: don’t make assumptions about the device your application is running on.
Don’t assume your users are all running the latest hardware and software (they’re not). Don’t assume they perform regular software and firmware updates (they don’t). Don’t assume that if you design for a specific device, users won’t install it on other devices (they will). Don’t assume that users will avoid application features that clearly aren’t supported by their device (they won’t, but they will tell you all about what happens when they try it).
Don’t even assume that the device is a phone (not all Android devices are). When you make assumptions about the environment in which your application will run in, you are simply introducing prerequisites to your application that require enforcement, limiting your user audience, and creating potential problem areas within your application.
So, just in case it was unclear, don’t make assumptions about your devices or your users. Now, we know what you’re thinking. If you don’t make assumptions, you have to handle every possible case, right? You have to settle for developing mediocre apps that suit everyone, using only core APIs, instead of developing awesome apps that take advantage of this optional feature or that kind of screen. Not so! And we’ll get to the ‘how’ in a moment.