New Features to Take Advantage of in the Android 6.0 API

On August 17, 2015, Google unveiled the official Android 6.0 SDK (API level 23), christening the new operating system Android Marshmallow. While the new OS has not officially been rolled out yet, the third and final developer preview is available for download on the Android Developers site and the SDK through Android Studio’s SDK Manager. This blog post will explore a few of the new features in the Marshmallow API—backing up app data, new authentication methods, and voice interactions—with a high-level overview of how to implement them in your apps.

A neat new feature in Marshmallow is Auto Backup for Apps, which is the OS’s backup service for all associated app data. As long as your app targets API level 23, an encrypted version of its data—whether it be user input or configuration settings—will be automatically backed up to the user’s Google Drive account (sans penalty to storage available in the account) and restored when necessary. Temporary files and caches are not backed up by default, but the inclusion/exclusion of data can be configured in the app manifest. This Auto Backup feature is especially useful when developing apps with a significant amount of customization settings and user data that must be maintained. Because the data is safely stored in the cloud, we can leverage this feature to back up user-specific data when a database is inconvenient.

Given the popularity of fingerprint sensors and the increasing use of smartphones for secure activities (e.g. making in-app/in-store purchases, checking bank statements), Marshmallow presents two new authentication APIs: Fingerprint Authentication and Confirm Credential. Both methods involve using the Android Key Store’s KeyGenerator class to create a key that can be used upon authentication (by fingerprint or by regular device credentials). For Fingerprint Authentication, your app can scan for a fingerprint and check it against the initial key via the FingerprintManager. Confirm Credential is in-app authentication piggybacking off the device’s lock screen authentication (PIN/pattern/password) based on how recently the device was unlocked. Here, you set a “validity duration” on the KeyGenerator and the user will not be required to re-authenticate in your app within this duration. Here is a Fingerprint Authentication sample and Confirm Credential sample for reference.

Voice commands are nothing new for Android, but the Marshmallow API now features voice interactions with the VoiceInteractor class. In other words, after a predefined voice action (or tap input), your app can ask a follow-up question prior to executing the action. This comes in handy if you want to confirm an action or provide the user with a list of options to pick from. To set up a voice interaction, you need to designate the voice interaction activity in the manifest and write this activity, which will be triggered upon a voice action. Finally, the interaction’s completion status must be sent to the calling VoiceInteractor for any consequent actions to occur.

Marshmallow is a major step up for Android users and developers alike, and I am excited to see the enhancements in the app world when 6.0 gets pushed to the public. In this post, I outlined a few of Android 6.0’s novel components, but there are many more that are brand new to the OS. A few notable changes worth looking at are App Linking, the Assist API, and new APIs for audio, video, and camera features. For a more in-depth look at the API, check out the Android Developers website or feel free to contact me at cmaier@westmonroepartners.com with any questions/comments. Happy developing!