Over a million developers have joined DZone.

Android N: Features and Benefits

DZone's Guide to

Android N: Features and Benefits

Not only does this article cover some of the new features we'll be seeing with Android N, but there are also some short tutorials for multi-window mode and inline reply.

Free Resource

Android NGoogle is releasing the next operating system for Mobile phone and tablets called Android N. It is the time to experiment and experience the new features of N, based on the developer preview. In this article, I am sharing my observations of the new features and give you a couple of short tutorials.

Multi-window Support

Android N allows the application multitasking using split screen mode. The user can split the screen by viewing a video on the left side while composing a message on the right side. The device fills the screen with two applications in side by side or one above the other.

Multi-Window Lifecycle

The activity lifecycle remains same in this mode. The activity having the recent interaction will consider as the foreground activity. The remaining activities will be in paused state which includes the activity which is sharing the screen.

While playing the video, there is no need to pause the video when an activity is in pause. To continue the video, we have paused the content in onStop() method, instead of onPause()method. To resume the video from we have to call onStart()method instead of onResume().Image title

Steps for Multi-window Mode

  1. Enable the multi-window mode by setting the android: resizeableActivityas true in the manifest file. The default value is true. The app will be launched in full-screen mode. Set android: supportsPictureInPictureto enable picture in picture display. This will not be worked if the resizable property is false.

  2. We can set the default size, location and minimum size of the activity. Refer the sample which is given below:

<activity android: name=".activities.SplashActivity"
        android: defaultHeight="400dp"
        android: defaultWidth="300dp"
        android:gravity = "top|end"
        android:minimalSize = "450dp"/>

There are some new methods introduced in multiwindow mode and we have listed below:


This checks the activity is in multi-window mode or not.


Use this method to check whether the activity is in picture-in-picture mode or not.

Note: It is an additional feature present in multi-window mode. If the Activity InPictureInPictureMode() returns true, then AndroidActivity.isInMultiWindowMode()will also be true.


This checks the activity is going into or out of multi-window mode. If the multi-window mode is activating in an activity then the system will pass the method a value of true and false when the activity leaves the multi-window mode.


This checks the activity is going into or out of multi-window mode. If the activity is going into picture-in-picture mode then the system will pass the method a value of true and false when the activity leaves

Fragments also available for these methods, for example Fragment.isInMultiWindowMode().

Launch Activity in Multi-window Mode by Intents

When we launching the new activity by intents, we can set the system that the new activity should launch in shared screen. We have to use Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT.

Virtual Reality VR-Mode

Android N added the support for new VR mode to developers. This enhances the performance by providing access to an exclusive CPU core for VR apps. It uses very low latency graphics.

This mode has a number of optimizations which will improve the VR application performance. The Google VR SDK is supporting both Daydream and Cardboard. It has both simple and complex API to develop the applications into Cardboard viewers with the support for daydream ready phones. We have an example that the Binocular rendering is a split screen view for each eye in VR which uses the controller class and lens distortion correction

Profile-guided JIT/AOT Compilation

In Android N, Android runtime (ART) maintains a profile for each app with hot methods precompiled and caches for best performance. It leaves the other parts of the app un-compiled until they are actually used. It improves the performance for key parts of the app and helps to reduce app's overall RAM footprint, including apps binaries.

Background Optimization by DOZE mode

The Doze mode saves battery by restricting the app's CPU and network activities when in the background or if the screen is off for a period of time or when the user is carrying the device in the pocket. Background process optimization has been updated in Android N version. If the application has implicit broadcasts it may start many background process which it has registered which will affect both device performance and user experience. We can improve the performance by removing the respective Broadcasts in the Application. It will make the app run on low memory devices or in low memory conditions. Otherwise, it may lead the application to Application Not Responding issues.

Android N gives the following restriction to achieve the background optimization:

The app will not receive the CONNECTIVITY_ACTION broadcast when it has registered in the manifest. But apps can still listen the CONNECTIVITY_CHANGE in the main thread by registering new receiver called Context.registerReceiver().

Apps will not support ACTION_NEW_PICTURE or ACTION_NEW_VIDEO receivers. It will affect all the existing app.

Enhancement on Bundled Notifications and Direct Reply

The notification messages will be grouped together based on the filters like message topic, title. For example, it will group the messages from hangout, Gmail as separate groups. To support group notification use the existing Builder.setGroup() method to bundle similar notifications.

By using direct reply, Users can quickly respond to their messages or update the task within the notification. Developers need to implement the new notifications APIs and guidelines to get the above features.

To support lower version compatibility, the same APIs are available with some support library. It will allow the developers to build notifications to work on earlier versions.

Steps to Add Inline Reply

  1. Start an instance of RemoteInput.Builderwhich has added to the notification action. It accepts the string which is going to be the key for input text. The app will use this key to retrieve the text from the input.

  2. Add RemoteInputobject to the existing action.

  3. Add the action to a notification and send the notification.

Steps to Retrieve User Input From the Inline Reply

  1. getResultsFromIntent()should be called by passing the action's intent as the input. It returns the bundle with the text response

  2. Query the bundle by key by creating a method by  RemoteInput.Builder.

  3. By using the same notification ID which has used in previous notification, build and issue another notification. The successful reply will be recognized by the disappearance of progress indicator. When working with this new notification, use the context that gets passed to the receiver's onReceive()method.

Sustained Performance Mode

In earlier versions, apps which push the CPU and GPU for extended periods in the background leads to heat up the device which results in a lag in application performance. To avoid this, the sustained performance mode has been introduced. The new API will provide a hint about the performance of the long-running applications. The App developers can use these hints to make the apps for the consistent level of performance.

General Behavior changes

If the user installs the existing applications directly in Android N then there will be changes in behavior. In some cases like the apps which are not handled the config changes properly, it will not work at all. So the developer needs to make the application compatible with the N preview.

android ,android n

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}