Dec 19, 2016



Introduction to Android Nougat: Android 7.0


Motorola Android 7.0 Nougat update list

New Features

Android Nougat introduces a variety of new features and capabilities, such as Multi-window Support, Notifications enhancements, and Data Saver. The following sections highlight these features and provide links to help you get started using them in your app.

Multi-Window Mode

Multi-window mode makes it possible for users to open two apps at once with full multitasking support. These apps can run side-by-side (landscape) or one-above-the-other (portrait) in split-screen mode. Users can drag a divider between the apps to resize them, and they can cut and paste content the between apps. When two apps are presented in multi-window mode, the selected activity continues to run while the unselected activity is paused but still visible. Multi-window mode does not modify the Android activity lifecycle.
You can configure how the activities of your Xamarin.Android app support multi-window mode. For example, you can configure attributes that set the minimum size and the default height and width of your app in multi-window mode. You can use the new Activity.IsInMultiWindowMode property to determine if your activity is in multi-window mode. For example:
if (!IsInMultiWindowMode) {
    multiDisabledMessage.Visibility = ViewStates.Visible;
} else {
    multiDisabledMessage.Visibility = ViewStates.Gone;
}
The MultiWindowPlayground sample app includes C# code that demonstrates how to take advantage of multiple window user interfaces with your app.
For more information about multi-window mode, see the Multi-Window Support.

Enhanced Notifications

Android Nougat introduces a redesigned notification system. It features a new Direct Reply feature that makes it possible for users to quickly reply to notifications for incoming text messages directly in the notification UI. Starting with Android 7.0, notification messages can be bundled together as a single group when more than one message is received. Also, developers can customize notification views, leverage system decorations in notifications, and take advantage of new notification templates when generating notifications.

Direct Reply

When a user receives a notification for incoming message, Android Nougat makes it possible to reply to the message within the notification (rather than open up the messaging app to send a reply). This inline reply feature makes it possible for users to quickly respond to an SMS or text message directly within the notification interface:
To support this feature in your app, you must add inline reply actions to your app via a RemoteInput object so that users can reply via text directly from the notification UI. For example, the following code builds a RemoteInput for receiving text input, builds a pending intent for the reply action, and creates a remote input enabled action:
This action is added to the notification:
The Messaging Service sample app includes C# code that demonstrates how to extend notifications with a RemoteInputobject. For more information about adding inline reply actions to your app for Android 7.0 or later, see the AndroidReplying to Notifications topic.

Bundled Notifications

Android Nougat can group notification messages together (for example, by message topic) and display the group rather than each separate message. This bundled notifications feature makes it possible for users to dismiss or archive a group of notifications in one action. The user can slide down to expand the bundle of notifications to view each notification in detail:
To support bundled notifications, your app can use the Builder.SetGroup method to bundle similar notifications. For more information about bundled notification groups in Android N, see the Android Bundling Notifications topic.

Custom Views

Android Nougat makes it possible for you to create custom notification views with system notification headers, actions, and expandable layouts. For more information about custom notification views in Android Nougat, see the Android Notification Enhancements topic.

Data Saver

Beginning with Android Nougat, users can enable a new Data Saver setting that blocks background data usage. This setting also signals your app to use less data in the foreground wherever possible. The ConnectivityManager has been extended in Android Nougat so that your app can check whether the user has enabled Data Saver so that your app can make an effort to limit its data usage when Data Saver is enabled.
For more information about the new Data Saver feature in Android Nougat, see the Android Optimizing Network Data Usage topic.

App Shortcuts

Android 7.1 introduced an App Shortcuts feature that makes it possible for users to quickly start common or recommended tasks with your app. To activate the menu of shortcuts, the user long-presses the app icon for a second or more – the menu appears with a quick vibration. Releasing the press causes the menu to remain:
This feature is available only API level 25 or higher. For more information about the new App Shortcuts feature in Android 7.1, see the Android App Shortcuts topic.

Sample Code

Several Xamarin.Android samples are available to show you how to take advantage of Android Nougat features:
  • MultiWindowPlayground demonstrates the use of the multi-window API available in Android Nougat. You can switch the sample app into multi-windows mode to see how it affects the app's lifecycle and behavior.
  • Messaging Service is a simple service that sends notifications using the NotificationCompatManager. It also extends the notification with a RemoteInput object to allow Android Nougat devices to reply via text directly from the notification without having to open an app.
  • Active Notifications demonstrates how to use the NotificationManager API to tell you how many notifications your application is currently displaying.
  • Scoped Directory Access Demonstrates how to use the scoped directory access API to easily access specific directories. This serves as an alternative to having to define READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permissions in your manifest.
  • Direct Boot Illustrates how to store data in a device-encrypted storage which is always available while the device is booted both before and after any user credentials(PIN/Pattern/Password) are entered.

Summary

This article introduced Android Nougat and explained how to install and configure the latest tools and packages for Xamarin.Android development on Android Nougat. It also provided an overview of the key features available in Android Nougat, with links to example source code to help you get started in creating apps for Android Nougat.

No comments:

Post a Comment