Some of the features of Lollipop 5.0 :
Concurrent documents and activities in the recents screen
Screen capturing and sharing
Camera API for advanced camera capabilities
Bluetooth Low Energy
Developer tools for battery usage
- Material design :
Android 5.0 adds support for Android””s new material design style. You can create apps with material design that are visually dynamic and have UI element transitions that feel natural to users. This support includes:
- The material theme
- View shadows
- The RecyclerView widget
- Drawable animation and styling effects
- Material design animation and activity transition effects
- Animators for view properties based on the state of the view
- Customizable UI widgets and app bars with color palettes that you control
Animated and non-animated drawables based on XML vector graphics
- Concurrent documents and activities in the recents screen :
In previous releases, the recents screen could only display only one task for each app that the user interacted with most recently. Now your app can open more tasks as needed for additional concurrent activities for documents. This feature facilitates multitasking by letting users quickly switch between individual activities and documents from the recents screen, with a consistent switching experience across all apps. Examples of such concurrent tasks might include open tabs in a web browser app, documents in a productivity app, concurrent matches in a game, or chats in a messaging app. Your app can manage its tasks through the ActivityManager.AppTask class.
Android 5.0 updates the WebView implementation to Chromium M37, bringing security and stability enhancements, as well as bug fixes. The default user-agent string for a WebView running on Android 5.0 has been updated to incorporate 18.104.22.168 as the version number.
This release introduces the PermissionRequest class, which allows your app to grant the WebView permission to access protected resources like the camera and microphone, through web APIs such as getUserMedia(). Your app must have the appropriate Android permissions for these resources in order to grant the permissions to the WebView.
- Screen capturing and sharing
Android 5.0 lets you add screen capturing and screen sharing capabilities to your app with the new android.media.projection APIs. This functionality is useful, for example, if you want to enable screen sharing in a video conferencing app.
The new createVirtualDisplay() method allows your app to capture the contents of the main screen (the default display) into a Surface object, which your app can then send across the network. The API only allows capturing non-secure screen content, and not system audio. To begin screen capturing, your app must first request the user’s permission by launching a screen capture dialog using an Intent obtained through the createScreenCaptureIntent() method.
Lock screen notifications
Lock screens in Android 5.0 have the ability to present notifications. Users can choose via Settings whether to allow sensitive notification content to be shown over a secure lock screen.
Your app can control the level of detail visible when its notifications are displayed over the secure lock screen. To control the visibility level, call setVisibility() and specify one of these values:
- VISIBILITY_PRIVATE: Shows basic information, such as the notification’s icon, but hides the notification’s full content.
- VISIBILITY_PUBLIC: Shows the notification’s full content.
- VISIBILITY_SECRET: Shows nothing, excluding even the notification’s icon.
When the visibility level is VISIBILITY_PRIVATE, you can also provide a redacted version of the notification content that hides personal details. For example, an SMS app might display a notification that shows “You have 3 new text messages” but hides the message content and senders. To provide this alternative notification, first create the replacement notification using Notification.Builder. When you create the private notification object, attach the replacement notification to it through the setPublicVersion() method.
Android 5.0 uses metadata associated with your app notifications to sort the notifications more intelligently. To set the metadata, call the following methods in Notification.Builder when you construct the notification:
- setCategory(): Tells the system how to handle your app notifications when the device is in priority mode (for example, if a notification represents an incoming call, instant message, or alarm).
- setPriority(): Marks the notification as more or less important than normal notifications. Notifications with the priority field set to PRIORITY_MAX or PRIORITY_HIGH appear in a small floating window if the notification also has sound or vibration.
- addPerson(): Enables you to add one or more people who are relevant to a notification. Your app can use this to signal to the system that it should group together notifications from the specified people, or rank notifications from these people as being more important.
Support for OpenGL ES 3.1
Android 5.0 adds Java interfaces and native support for OpenGL ES 3.1. Key new functionality provided in OpenGL ES 3.1 includes:
- Compute shaders
- Separate shader objects
- Indirect draw commands
- Multisample and stencil textures
- Shading language improvements
- Extensions for advanced blend modes and debugging
- Backward compatibility with OpenGL ES 2.0 and 3.0
The Java interface for OpenGL ES 3.1 on Android is provided with GLES31. When using OpenGL ES 3.1, be sure that you declare it in your manifest file with the <uses-feature> tag and the android:glEsVersion attribute. For example:
|<manifest><uses-feature android:glEsVersion=”0x00030001″ />
- Camera API for advanced camera capabilities
Android 5.0 introduces the new android.hardware.camera2 API to facilitate fine-grain photo capture and image processing. You can now programmatically access the camera devices available to the system with getCameraIdList() and connect to a specific device with openCamera(). To start capturing images, create a CameraCaptureSession and specify the Surface objects to send captured images. The CameraCaptureSession can be configured to take single shots or multiple images in a burst.
- Bluetooth Low Energy :
Android 4.3 introduced platform support for Bluetooth Low Energy (Bluetooth LE) in the central role. In Android 5.0, an Android device can now act as a Bluetooth LE peripheral device. Apps can use this capability to make their presence known to nearby devices. For instance, you can build apps that allow a device to function as a pedometer or health monitor and communicate its data with another Bluetooth LE device.
The new android.bluetooth.le APIs enable your apps to broadcast advertisements, scan for responses, and form connections with nearby Bluetooth LE devices. To use the new advertising and scanning features, add the BLUETOOTH_ADMIN permission in your manifest. When users update or download your app from the Play Store, they are asked to grant the following permission to your app: “Bluetooth connection information: Allows the app to control Bluetooth, including broadcasting to or getting information about nearby Bluetooth devices.”
- Scheduling jobs :
In addition to new features, Android 5.0 emphasizes improvements in battery life. Use the new APIs and tool to understand and optimize your app’s power consumption.
Android 5.0 provides a new JobScheduler API that lets you optimize battery life by defining jobs for the system to run asynchronously at a later time or under specified conditions (such as when the device is charging). Job scheduling is useful in such situations as:
- The app has non-user-facing work that you can defer.
- The app has work you””d prefer to do when the unit is plugged in.
- The app has a task that requires network access or a Wi-Fi connection.
- The app has a number of tasks that you want to run as a batch on a regular schedule.
Use the JobInfo.Builder class to configure how the scheduled task should run. You can schedule the task to run under specific conditions, such as:
- Start when the device is charging
- Start when the device is connected to an unmetered network
- Start when the device is idle
- Finish before a certain deadline or with a minimum delay
For example, you can add code like this to run your task on an unmetered network:
|JobInfo uploadTask = new JobInfo.Builder(mJobId, mServiceComponent /* JobService component */).setRequiredNetworkCapabilities(JobInfo.NetworkType.UNMETERED)
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
If the device has stable power (that is, it has been plugged in for more than 2 minutes and the battery is at a healthy level), the system will run any scheduled job that is ready to run, even if the job’s deadline has not expired.
- Developer tools for battery usage :
The new dumpsys batterystats command generates interesting statistical data about battery usage on a device, organized by unique user ID (UID). The statistics include:
- History of battery related events
- Global statistics for the device
- Approximate power use per UID and system component
- Per-app mobile ms per packet
- System UID aggregated statistics
- App UID aggregated statistics
Use the –help option to learn about the various options for tailoring the output. For example, to print battery usage statistics for a given app package since the device was last charged, run this command:
|$ adb shell dumpsys batterystats –charged <package-name>|