When building an Android app, you face a fundamental decision: create a single app version supporting multiple device types, or upload separate optimized versions to Google Play Store.
Single App vs Multiple Apps
Single App Approach:
- ✅ Less code to maintain
- ✅ Greater scalability
- ❌ Requires device-specific routing logic
Multiple App Approach:
- ✅ Google Play handles filtering upfront
- ❌ Bug fixes require multiple app updates
The Solution: Utility Methods
Google’s IO Sched application provides an excellent example of the single-app approach. Here are the key utility methods for device detection:
public class UIUtils {
public static boolean hasHoneycomb() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
}
public static boolean isTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
public static boolean isHoneycombTablet(Context context) {
return hasHoneycomb() && isTablet(context);
}
public static boolean isGoogleTV(Context context) {
return context.getPackageManager()
.hasSystemFeature("com.google.android.tv");
}
}
Practical Implementation
Using the Facade pattern, you can conditionally load different activities based on device type:
Intent intent;
if (UIUtils.isTablet(this)) {
intent = new Intent(this, MapMultiPaneActivity.class);
} else {
intent = new Intent(this, MapActivity.class);
}
startActivity(intent);
This approach lets you maintain a single codebase while still providing optimized experiences for different device form factors.
Credit
These utility methods are derived from Google’s open-source IO Sched application code.