Android 5 Lollipop new API and Feature

By Arvind Rai, October 18, 2014
In this page, we will get the overview of android 5 Lollipop also known as Android L. This release has lots of new API and feature that makes android 5 more secure, more flexible for app, multitasking, support for 64 bit system. There are so many new changes related to notification. New API are there to get better control of devices. New API has been added to feel metallic color to improve graphics. Find the detailed over below of android 5 Lollipop.

Change in targetSdkVersion

To support android 5 we need to change our targetSdkVersion as "21". The existing app needs to change it and upload it.

New in Notifications

Notifications allows users to get relevant information from the apps. There are some new additions in Notifications in android 5.
1. Now notification can be captured with visual changes.
2. If device is lock, still we are able to get notification that will hide secure information too.
3. If an important notification received and device is busy, still we are able to get notification as heads-up notification.
4. If we dismiss any notification in our one android device, it will automatically be dismissed in our other android devices too. It is achieved by Cloud-synced notifications.

Use Notification.Builder for Sound and Vibration

Before android 5, we use Ringtone, MediaPlayer, or Vibrator classes. Now to supports android 5 notification, we should not use these classes. In android 5, use Notification.Builder to support sound and vibration like task. There are now change in behavior of RINGER_MODE_SILENT. If we set the device to RINGER_MODE_SILENT, that will cause new propriety mode.

Changes in Lock screen visibility: use of setPublicVersion()

In android 5, by default notification will be displayed if screen is locked. But we can change this setting to hide any secured data. Use the method setPublicVersion(), to change the notification. To allow media playback control on the notification, use setVisibility() and can set values like VISIBILITY_PUBLIC.

Use MediaSession class instead of RemoteControlClient

In android 5 or API level 21, RemoteControlClient class has been deprecated. To provide a better experience in locked and un-locked screen, media playback control is being used. Notification.MediaStyle has been introduced in android 5 that changes notification actions into buttons in media playback notification.

Change in Recent Screen: Concurrent documents and activities now supported

Before android 5, recent screen was able to display only one screen for each app that was visited latest by user. Now we can develop the app that can open more than one task for other parallel processing. In this way, this supports multitasking. Previously ActivityManager.getRecentTasks() was being used to get recent task, now it has been deprecated. We should use getAppTasks() in android 5. For Concurrent documents and activities, find some of the API introduced in android 5 or API level 21.
ActivityManager.AppTask: This class has been added to manage the task owned by our app.
android:maxRecents : Sets the max number of recent task.
FLAG_ACTIVITY_NEW_DOCUMENT : This flag is used to treat the system as a new task when activity starts.

Support for 64-bit Systems

Android 5 supports 64-bit systems. In this way the performance has been increased. There is backward compatibility. Still 32-bit apps will be supported by android 5. To work on supporting 64-bit Systems, we need to install NDK Revision 10c.

Change in Behavior of Context.bindService()

Before android 5, Context.bindService() was working with implicit intent. Now this will throw exception. Context.bindService() should be given explicit intent. This will help to increase the security level in apps.

Addition of Material Design

Now in android 5, we can develop Material Design that will increase the experience of visual, motion and interaction and make us feel natural. Android 5 has introduced material theme, view shadows, RecyclerView widget, Drawable animation, Material design animation, activity transition effects, Customizable UI widgets etc. to support material design functionality.

Added PermissionRequest in WebView

PermissionRequest class has been added in in WebView that will supports security and stability. PermissionRequest helps to access protected resources by web API using getUserMedia(). The protected resources are like camera and microphone.

Addition of android.media.projection API

Screen capturing and screen sharing capabilities has been added in android 5 using android.media.projection API. Screen sharing can be done in video conferencing.

Support for OpenGL ES 3.1 in Graphics

Now in android 5, java interfaces and native support are there for OpenGL ES 3.1. This supports Compute shaders, Separate shader objects, Indirect draw commands, Multisample and stencil textures etc. To enable OpenGL ES 3.1, do the following changes in android manifest as below.
<manifest>
    <uses-feature android:glEsVersion="0x00030001" />
    ...........................
</manifest> 

Added Extension Pack

Android Extension Pack has native supports for advanced graphics functionality like Guaranteed fragment shader support, Tessellation and geometry shaders, ASTC (LDR) texture compression format and Per-sample interpolation and shading support. To enable advanced extension pack do the following changes in manifest.
<manifest>
    <uses-feature android:name="android.hardware.opengles.aep"
        android:required="true" />
    ...
</manifest> 

Added New android.hardware.camera2 API

In android 5, there is a new camera API that is android.hardware.camera2. Now photo capturing are more clear. getCameraIdList() and openCamera() facilitates to access camera devices programmatically.

Changes in Audio playback and Media playback control

In android 5, there are some addition of API for Audio playback and Media playback control. ENCODING_PCM_FLOAT enables our audio data to be supplied in floating-point format. Our app can also send audio data as ByteBuffer.
In media playback control, MediaSession class has been introduced that handles callback methods and media buttons. MediaController class enables us to create our own media controller app.

Addition of android.media.browse API

android.media.browse API enables us to browse the media content library. Our service class will extend MediaBrowserService and should provide access to MediaSession.Token. In this way the app will be able to play media content provided by us.

Storage Access Framework

Android 5 has introduced Storage Access Framework that will enable to walk tree and sub tree of a directory by single confirmation. No need of confirmation for each directory. The API buildChildDocumentsUriUsingTree() and buildDocumentUriUsingTree() helps to traverse the directory.

Multiple network connections

In android 5, our app can select a network connection dynamically and connect to them using multi-networking API. To perform this task, first create a ConnectivityManager then use NetworkRequest.Builder class to create NetworkRequest. To select network use requestNetwork() or registerNetworkCallback().

Addition of android.bluetooth.le API

android.bluetooth.le API enables our app to communicate with other Bluetooth device. It can broadcast the messages and will scan for responses. To enable this functionality we need to add BLUETOOTH_ADMIN permission in android manifest file. ScanFilter class enables apps to scan only specific type of device.

NFC enhancements

Find the following NFC enhancements in android 5.
1. Android Beam is added in share menu.
2. invokeBeam() method will invoke android beam.
3. createTextRecord() method creates an NDEF.
4. Helpful in developing in payment app.

Scheduling jobs and Improvements in Battery Life

Android 5 API has new enhancement by using which there is improvements in battery life. Battery life has been improved by running job synchronously or when battery is charging. Job can be scheduled for such conditions like app has non-user facing work. Android 5 enables to schedule the job of different type like do the processing when Wi-Fi connected, assign a batch job for regular processing etc.

Managed provisioning and Device owner

In an enterprise environment, our app can run in different way now by managed provisioning in android 5. To start it call ACTION_PROVISION_MANAGED_PROFILE in an Intent. By default there is lesser number of app in profile but we can add more using enableSystemApp() method.
In android 5, we can install device owner app. This is a type of administrator that can add and remove secondary users.

Screen pinning

In android 5, Screen pinning can be achieved. This is a mode that will lock the screen temporally. In this mode, user cannot switch to other screen like home page and no notification will be displayed. We can do screen pinning by two way manually and programmatically.

Render PDF as bitmap

A PDF file can be rendered into bitmap for printing. The new class PdfRenderer will be used. openPage() opens the page and render() method will render PdfRenderer.Page type into bitmap.

App usage statistics, Testing and Accessibility API

In android 5, new API has been added for app usage statistics, testing and accessibility.
android.app.usage : This provides detailed usage information.
getWindowAnimationFrameStats() and getWindowContentFrameStats(): Captures frame statistics.
executeShellCommand() : Allows to use shell commands.

Easily Switching to Enter Data from One language to Another Language

Now with android 5, a user can easily switch input language. The method shouldOfferSwitchingToNextInputMethod() and switchToNextInputMethod() helps to implement this feature.

Declare required Feature for the App in Manifest

Now we can tell our android manifest that these are the required feature to run the app like FEATURE_AUDIO_OUTPUT, FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING, FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR, FEATURE_CAMERA_CAPABILITY_RAW etc.

BIND_DREAM_SERVICE Permission

BIND_DREAM_SERVICE is a user permission that is supported by <uses-permission> element in android 5. DayDream service requires this permission in target API level 21.

Reference

Android 5.0 APIs
POSTED BY
ARVIND RAI
ARVIND RAI







©2024 concretepage.com | Privacy Policy | Contact Us