Android (Java), App & Software, Development, Mobile, News, Tech, Technology, Tutorials

Android Marshmallow: Changes required in your current app!

Android M by Takahiro Yamagiwa (Flickr) Image Courtesy: Takahiro Yamagiwa (Flickr)

Since Android Marshmallow has rolled out its latest Android SDK version 6.0, all app developers should make their app ready for the latest version as there are many direct and indirect impacting features. We are bringing you the key points that you need to take care of in order to make your app ready for the new Android Marshmallow, as soon this version will be rolled out for many devices.

What changes are needed in your current app to make sure it runs smoothly on Marshmallow?

If you are updating the compileSdkVersion of your android app project to 23, then make sure you take care of the following new features that might effect your app:

1) Runtime Permissions:

Devices with the new Android M will no longer give you access to various permissions like network access, read contact, read messages etc. automatically just by declaring in manifest file. Now you need to first check for the permission by calling the new checkSelfPermission() method. And if you do not have the required permission, then call the new requestPermissions() method to get permission from user. Note, to make your app backward compatible you must version 23 of the V4 support library. Also, change the targetSdkVersion to 23 to test the new permission behaviour.

To know more on how to implement the new runtime permission in your app, read here.

2) Doze and App Standby:

These are the two new power saving mode in Android M. These mode are definitely going to affect your app because in these new modes many operations are suspended as the device goes in power saving and sleep mode. Let’s study in detail each mode to see how much are they going to effect your app.

Dose:

The Doze mode is introduced to conserve battery by restricting apps’ access to network and CPU-intensive services when a user leaves a device unplugged and stationary for a period of time, with the screen off. However, these operations are resumed periodically for a brief amount of time. So, it is not going to affect your current app much but you still need to optimise the way that your app manages network, alarms, jobs, and syncs.

Also, you need to closely review the logic of how you have implemented alarm manager. As while in dose mode, the alarms are not fired. So if you still want to fire an alarm even while in dose mode, then you need to use the setAndAllowWhileIdle() and setExactAndAllowWhileIdle() methods. But note there are restrictions to these too, as the these methods can not fire alarms more than once per 15 minutes per app.

Another, thing that will affect app in dose mode is the restriction of network access. So, if your app requires persistent network connectivity for real-time messaging, then definitely in dose mode your app may not function as required.

App Standby:

App standby is a more restrictive mode. The system restricts all network access and sync jobs in this mode. So, if app is not running any process in foreground, or user has not explicitly launch the app, or the app does not have any notification on the lock screen or notification tray then the system will assume that the app is in idle mode and will restrict its network access and other sync jobs. In app standby mode the system will allow network access to the app only once a day.

To know more about optimising your app for dose and app standby mode, read out here.

3) Removed Deprecated classes and features:

You need to check your app for usage of deprecated classes as many classes and APIs have been removed from new Android M. For example, the support of Apache HTTP client has been removed in Android 6.0. Also, it is moving away from OpenSSL to BoringSSL and the support for OpenSSL would be removed from upcoming releases and devices without any notice.

There are many other methods whose support has been removed in Android 6.0 like, the Notification.setLatestEventInfo() , android.provider.Browser.getAllBookmarks() andandroid.provider.Browser.saveBookmark() methods.

To check the whole list of removed classes and methods, read out here.

4) APK Validation

Android 6.0 is more stricker on APK validation now. So, if you have declared a file in manifest and that file in not present in your apk, then your apk will be considered as corrupt. So, before rolling out your apk you must update your manifest for any removed file and rebuild the apk.

5) Google Play Service v8.3

If your application is using the Google Play services SDK, then you need to update to the latest version, 8.1, which is compatible with the new runtime permissions introduced in Android 6.0 Marshmallow. You may also need to optimize your app by using new simplified features provided by the new google play service 8.3. For example, with new play services you can implement google API client authentication in a single click as it no longer requires system permission to get a signed-in account. Also, the fused location is optimized for battery consumption and you should upgrade it for Android M.

 

The changes listed above are basic ones to give you an idea of what majorly has changes in Android Marshmallow 6.0. There are also new features and methods introduced which you may or may not want to use in your app for now. To check all the new features added in Android Marshmallow read here.

You Might Also Like