luni, 31 decembrie 2012

Important Android 4+ (post ICS) Tools

Android is a platform that for better or for worse runs on wide variety of devices and causes a lot of “fragmentation” complaints by less experienced developers. And while the screen/resolution issues can be decently solved by having a competent designer (see: web development), version fragmentation poses a more significant problem – only 6,7% of all Android devices run 4.1.x versions, while the rest are suck on older Androids with little hope for update.




Android version distribution

Ice Cream sandwich (and Honeycomb before it) brought significant improvements to the Android API, which significantly ease cross-device development and thanks to efforts of several developers a large part of those changes were backported in form of libraries for Android 2.x.

Below you can find a list with some of the most useful such libraries which are also used in some of our apps.

Android Support Package

This is official Google library which backports Fragments and Loaders.
Fragments add a way to manage only part of displayed activity life-cycle and are critical part of tablet user interfaces – especially if you want to develop apps which work on phones and tablets without publishing separate APKs.
Loaders are a high-level interface for retrieving data from slow sources (network or database). Android runtime caches the loaders by their ID across Activity life-cycle, which means easy management and caching of remote data without writing boiler-plate AsyncTask code to keep state across orientation changes.


Action Bar Sherlock

ABS is a library by Jake Wharton that backports the Action bar API to Android 2.x.

Action bar is a new Android paradigm, which is composed of a top bar with application name and implements tab navigation, menu replacement and “up” navigation. Pretty much any Android app has an action bar (or at least should have) and this API is the easiest way to implement it. It also handles tab navigation with optional split mode (you should not use TabHost anymore) and menu buttons on devices without physical keys (e.g. Galaxy Nexus) and moves icons to menu when screen space runs out.

Pull-to-Refresh

Pull-to-Refresh allows you to implement the iOS-ish paradigm of pulling a ListView to refresh content.



NOTE: Pull-to-refresh is a distinctly non-Android way of refreshing content, I suggest adding a separate “Refresh” option to the menu (e.g. like Boid Twitter client) to avoid user confusion.

ViewPagerIndicator

Android Support Library also adds support for horizontally scrolling ViewPager, which allows you to put several fragments side by side and allow user to swipe between them. However, the API is missing a position indicator similar to the one in Google+ and Play Market apps. Such customizable indicator is provided by ViewPagerIndicator library.
View pager indicator tabs