Google served Nougat on the table early September this year. Nexus 5X and 6P were the first devices to get the Nougat update. Slowly other devices from popular brands started catching up.

Now as an Android developer, this is probably the best time for you to get your app ready and fully compatible with Android Nougat. The sooner you do it, the better experience you can create for your users. After upgrading their OS, your users would expect your app to be fully compatible and offering the latest features that Nougat brings to the table.

Android 7.0 brings some really cool features and enhancements that can make your app stand out from the rest. And you won’t even need to take a lot of time to learn and implement these new things. So without wasting any time further, let’s get started.

Java 8 Language Features

If you are a regular Java developer, you must know the awesome features Java 8 brought to us. But the sad part was that Android didn’t support Java 8 natively.

But these are all sad stories of the past, as Android Nougat brings some of the really amazing Java 8 features with the help of Jack toolchain. If you are a lazy developer who likes to write less code, specially those boring boilerplate ones, then this is just for you.

If you haven’t heard of Lambda Expressions yet, then it is something which can turn your code from this,

mButton.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

doSomethingCrazy();

}

});

magically to this,

button.setOnClickListener(v -> doSomethingCrazy());

and with the aid of Method References, things get even more crazy like this,

button.setOnClickListener(this::doSomethingCrazy);

And the best thing is, all of these amazing features are backward-compatible to API level 9, so no worries at all.

Some of the other cool Java 8 features that Nougat offers (which are not backward-compatible) are the Stream APIs, with which instead of using the same old boring for-loops, you can do something like this,

String name = persons.stream()

.filter(n -> "John".equals(n.getName()))

.map(Person::getName)

.findAny()

.orElse("");

The old interfaces in Java also got an update with default and static methods in Java 8.

If your development life was slightly getting boring these days, then with these cool new features it is surely going to get pumped up a lot.

Bonus: Read more about all Java 8 features and how to implement them in the detailed guide here.

Split-Screen Multi-Window Feature

If you have used some Samsung devices before, you surely know what multi-window actually is, but now this feature is available natively in all Android Nougat devices.

Multi-window (or split-screen) basically allows two apps to be viewed and used simultaneously in a single screen. Just image yourself browsing the web and checking your social media feed, both at the same time.

And the good news is, multi-window is enabled by default for all apps targeting Nougat and above. Now in multi-window mode the apps can get resized by the user and the minimum size can go down to even 200dp height and 200dp width. Just imagine, how insanely small the available screen space is going to get for your app and how challenging it can be to show some useful content to the users in such a small screen space.

The first thing you need to learn before implementing multi-window is how to make a properly responsive UI design which can cater to a wide variety of screen sizes seamlessly. And the best place to start is here and here.

So the question is not if your app supports multi-window, but its about how well it does that.

Pro Tip: You can learn more about implementing multi-window from here and here.

Recommended Reading

Direct Reply for Notifications

You won’t see a huge change in the user-interface in Nougat, but the one thing that you are bound to notice immediately is the completely revamped notifications tray. This is the one thing that got a full makeover and it looks really gorgeous and minimalistic.

If your app makes heavy use of notifications to communicate with your users, then you should implement these new enhancements to make your app stand out from the rest.

Few small changes added together can make a big differences.

The first thing you should look into is the Direct Reply feature, specially if you have an app like a messaging app or an email app. This lets your users directly reply to message or conversations right from the notifications, without even entering the app. This practically reduces the number of steps from the user to the action to a big zero.

For implementing this, you need to make proper use of the RemoteInput API which is responsible for taking inputs remotely from your users and forwarding it into your app.

If you are accustomed with programming in Android Wear already, this is exactly the same API used in Voice Input there. Here are just 3 quick steps to implement Direct Reply into your app,

Create an instance of RemoteInput.Builder that you can attach to your notification later,

// The key to accept direct replies

private static final String KEY_DIRECT_REPLY = "key_direct_reply"; // Create a RemoteInput with this key

String label = getString(R.string.label);

RemoteInput remoteInput = new RemoteInput.Builder(KEY_DIRECT_REPLY)

.setLabel(label)

.build();

2. Attach the RemoteInput object to the action using the addRemoteIput() method,

// Add the remote input to the action

Notification.Action action =

new Notification.Action.Builder(R.drawable.ic_reply,

getString(R.string.label), replyPendingIntent)

.addRemoteInput(remoteInput)

.build();

3. Add the action to the notification and notify it,

// Build the notification and add the action

Notification newNotification =

new Notification.Builder(mContext)

.setSmallIcon(R.drawable.ic_message)

.setContentTitle(getString(R.string.title))

.setContentText(getString(R.string.content))

.addAction(action))

.build(); // Notify the notification

NotificationManager notificationManager =

NotificationManager.from(mContext);

notificationManager.notify(notificationId, newNotification);

Do More With Bundled Notifications

Another cool thing in this aspect is the Bundled Notifications feature. If your app is heavily dependent on notifications, you must implement this.

Neither would it be possible for you to just send a single notification and communicate everything to the user with that, nor it is a good practice to send several notifications and clutter the entire notifications tray.

Bundled notifications takes the good things from both the worlds and combines them to make the user experience really simple and amazing. If you have a chat app or a messaging app, your users will be significantly benefited from this feature.

It is very simple to implement as well. Just make proper use of setGroup() and setSortKey() to properly group and sort similar notifications for a richer experience. More on this, here.

Bonus: If you are struggling to implement these notification related features going through the docs, here is a perfectly working project showcasing the implementation. You can thank me later.

Recommended Reading

Enhanced Doze Mode

Battery consumption is something that almost all users are constantly worried about. So, we as developers need to take extra care while developing our apps and ensure that they don’t become a battery hungry monster.

As you know, Android Marshmallow introduced the Doze mode which defers all background jobs, Wifi scans, alarms as long as the device is not plugged in, the screen is turned off and the device is stationary.

The idea was great, but it is now even better and efficient in Nougat as they have extended the Doze mode to save even more battery. Initially, the Doze mode only worked when the device was completely stationary (like on a shelf or a table), but now it will also work on the go when in your pocket.

In this model, a lighter version of Doze will trigger with a smaller set of restrictions (no network access, deferred jobs) and will run on regular small maintenance windows.

If you had taken care of your app for Doze in Marshmallow, you actually don’t need to do anything extra for Nougat. But if you haven’t, then it is highly recommended to make your app battery friendly. You can have a good start here.

Get Your App Ready for Direct Boot

Direct Boot allows apps like alarm clock, messaging, email, todo-list or any other app where showing timely notifications is of utmost importance, to run in a limited environment and do their time-critical work even if the device is still not unlocked.

You might not need to implement Direct Boot if your app doesn’t fall in any of the categories mentioned above. But if it does and you have decided to implement Direct Boot, you need to identify the components of your app that should run in a limited environment even before the device is not unlocked.

Now before your app is completely ready for Direct Boot, you need to move all the data which are accessed by these direct boot aware components to the device protected storage area. The default storage area for any app is the credential protected storage area which is only available when the actual device is unlocked by the user using his/her credentials.

You should decide carefully what you are going to store in the device protected storage area and leave the rest in the credential protected storage area. You should read this detailed guide about implementing direct boot here.