Micro Focus is now part of OpenText. Learn more >

You are here

You are here

Android Nougat: Cool features every mobile app should support

public://webform/writeforus/profile-pictures/pic_3_0.jpg
Aritra Roy Android Developer, Treebo
Fresh nougat
 

Google served up Android 7.0 in early September, and while the Nexus 5X and 6P were the first devices to get the Nougat update, other brands and models are just starting to catch up. With these recent advances in the state of the art in mobile development, now is good time for all good Android developers to get their apps ready. 

Once your customers have upgraded to Nougat, they're going to expect your app to be fully compatible—and to support the latest features that Nougat brings to the table. Are you ready?

Android 7.0 brings some cool features and enhancements that can make your app stand out from the rest. Best of all, you won’t need to spend much time to learn and implement these new features. Here's what's in store.

Nougat's cool new Java 8 features

If you are a regular Java developer, you already know the awesome features that Java 8 offers. Sadly, Android didn’t support Java 8 natively until now.

Android Nougat brings support for Java 8's features with the help of the Jack toolchain. If you are a lazy—ahem, efficiency minded—developer who likes to write less code, especially those boring boilerplate ones, this is for you.

For those who haven’t heard of lambda expressions yet, this is something that can turn your code from this...

mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doSomethingCrazy(); } });

... to this

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

With the aid of method references, things get even more crazy, like this:

button.setOnClickListener(this::doSomethingCrazy);

Best of all, all of these features are backward compatible to API level 9. 

Another cool Java 8 feature available in Nougat (but that is not backward-compatible) are the stream APIs, which, instead of using the same old boring for-loops, let you do something like this:

String name = persons.stream() .filter(n -> "John".equals(n.getName())) .map(Person::getName) .findAny() .orElse("");

Google also updated the old interfaces in Java with the default and static methods in Java 8. If your development life was slightly getting boring, then with these new Java 8 language features should get you pumped.

Split-screen multi-window feature

 

Android 7.0's multi-window, or split-screen, lets users view and use two apps side-by-side on a single screen. Just picture yourself browsing the web and checking your social media feed at the same time.

The good news here is that multi-window is enabled by default for all apps targeting Android 7.0 and above. In the multi-window mode, the user can resize apps to a minimum of 200 by 200. Just imagine how insanely small the available screen space is going to get for your app, and how challenging it will be to show useful content to users in such a small space.

But before implementing multi-window you need to understand how to make a properly responsive UI design that can cater to a wide variety of screen sizes seamlessly.  The question is not if your app will support multi-window, but how well it will do so. 

Direct reply for notifications

 

You won’t notice a huge change in the user interface in Android 7.0 overall, but one area, the notifications tray, has been completely revamped. The new look is minimalistic—and gorgeous.

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

Sweating the small stuff

In terms of smaller changes, the first thing to check out is the direct reply feature, especially if you have a messaging or email app. Direct reply lets users reply to a message or a conversation directly from within the notification itself, without ever entering the app. This effectively reduces the number of steps the user must take to respond.

To implement this feature, you'll need to make proper use of the RemoteInput API, which takes inputs remotely from users and forwards them to your app. 

If you are accustomed to programming in Android Wear already, you'll be happy to hear that this is the same familiar API used in voice input. Follow these three quick steps to implement direct reply into your app:

  1. 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);

Fun with bundled notifications

 

Bundled notifications is yet another cool feature. If your app is heavily dependent on notifications, you absolutely must implement this.

You can't send just one notification to communicate everything to the user, nor is it good practice to send several notifications and clutter the entire notifications tray.

Bundled notifications combine the best of both worlds to make the user experience simple. If you have a chat or messaging app, users will benefit significantly from this feature, which is simple to implement. Just make proper use of setGroup() and setSortKey() to properly group and sort similar notifications for a richer experience. 

If you find yourself struggling to incorporate notification-related features, here is a perfectly working project that showcases an implementation

Use enhanced doze mode to reduce battery load

Virtually all mobile users fret about battery consumption, so most app developers are careful not to create a battery-hungry monster. That's why you may already be supporting doze mode.

Android's Marshmallow release first introduced doze mode, which defers all background jobs, Wi-Fi scans, and alarms as long as the device is not plugged in, the screen is turned off and the device is stationary.

Android 7.0 takes this great idea and makes it even better. Before, doze mode only worked when a device was completely stationary. Now it also works when users are the go.

 

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

If you app supported doze in Marshmallow, you don’t need to do anything to use the upgraded feature in Nougat. But if you haven’t, I highly recommend using this feature to make your app battery friendly. 

Get ready for direct boot

Direct boot lets apps such an alarm clock, messaging, email, to do list programs or any other app where showing timely notifications matters, run in a limited environment and do time-critical work even when the device is locked.

You might not need to use direct boot for your app. But if you need this capability, and you decide to implement direct boot, you must identify the components of your app that you want to run in a limited environment, even before the user unlocks the device.

Before your app is completely ready for direct boot, you need to move all of the data to be accessed by direct boot-aware components to the device's protected storage area. The credential-protected storage area is the default storage area for any app, and that is only available when the user unlocks the device.

Decide carefully what you are going to store in the device protected storage area, and leave the rest in the credential protected storage area. And before starting, be sure to read the detailed guide on implementing direct boot on the Android Developer's Blog .

Now get your Nougat game on

The major features I described above are just some of what's available in Android 7.0. Learning and incorporating all of these features into your app won't take more than a few days of your time, but the payoff with your users will be great: They'll see a huge improvement in the user experience. Once you give them a taste of a Nougat-optimized app, they'll never want to go back—or to your competitors.

Keep learning

Read more articles about: App Dev & TestingApp Dev