Android Team has just announced Android 5.1, updated version of Android 5.0 Lollipop platform. Like often, this new version comes with a better stability, bug fixes and obviously better performance. This Lollipop update brings to developers Android 5.1 SDK with API Level 22. This new SDK version supports new platform and will let to developers to use new features introduced with Android 5.1.

Multiple SIM Card Support

Android 5.1 introduces a small set of new APIs for developers. Most important thing is support for Multiple SIM Card. It lets users activate and use additional SIMs on devices that have two or more SIM card slots.

This feature is very important for many regions where Android One phones are being adopted. In India for example, device without multi SIM support are no chances to be sold. This new feature must offer to consumers of Android One devices more flexibility to switch between carriers and manage their network activities in the way that works best for them. Besides, as a developer, you can thus create app experiences that take advantage of this new feature.

Developers will access informations about currently active SIM through the new SubscriptionManager class.  They could know if device is considered to be roaming or no on the current network. Application could be alerted to changes in a device’s current network connection by requesting the READ_PHONE_STATE permission and setting SubscriptionManager.OnSubscriptionsChangeListener on the SubscriptionManager object thanks to addOnSubscriptionsChangedListener method.

Deprecated HTTP Classes

With Android 5.1, the org.apache.http and the AndroidHttpClient class have been deprecated. Theses classes won’t be maintained in the future. The impact is important because a lot of developers use this classe to make HTTP request on Android applications. A big work of migration should be made. To replace use of AndroidHttpClient, you must now use the URLConnection classes.

For example, to get a document with HTTP protocol, you can use the following code :


URL url = new URL("http://www.ssaurel.com/kakuro/qr_code_kakuro.png");
URLConnection urlConnection = url.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());

try {
   // get data by reading input stream ...
} finally {
   in.close();
}

 

Carrier Services

Carrier Service API has been added to the TelephonyManager class, the SmsManager class and the new CarrierMessagingService class. With this service, Android 5.1 provides support for telecommunication service providers to create apps that can perform provisioning tasks on an Android device. These APIs provide a secure and flexible way for carrier-developed apps to perform these tasks and be distributed through Google Play.

To check if they have access to these APIs, apps must call the hasCarrierPrivileges() method of TelephonyManager class. Call Carrier Service API without allowed access can provoke a SecurityException.

How to use Android 5.1 SDK ?

Nexus devices will have updates for Android 5.1 in the next few weeks. To start to try Android 5.1, the best solution is to use an Android 5.1 system image with the Emulator or to flash your Android device. As a developer, you will have to update Android SDK tools to support the new platform and its new APIs. SDK can be updated through the Android SDK Manager in Android Studio.