diff --git a/docs/html/preview/api-overview.jd b/docs/html/preview/api-overview.jd index 40618a34fb35f..2fa029fb90292 100644 --- a/docs/html/preview/api-overview.jd +++ b/docs/html/preview/api-overview.jd @@ -15,7 +15,9 @@ sdk.platform.apiLevel=20
L is an upcoming release for the Android platform -that offers new features for users and app developers. This document provides -an introduction to the most notable new APIs.
+The L Developer Preview gives you an advance look at the upcoming release for +the Android platform, +which offers new features for users and app developers. This document provides +an introduction to the most notable APIs.
-L is currently available as a developer preview intended -for early adopters and testers. If you are interested in influencing the -direction of the Android framework, -give the L Developer Preview a -try and send us your feedback!
+The L Developer Preview is intended for developer early adopters and +testers. If you are interested in influencing the direction of the +Android framework, give the L +Developer Preview a try and send us your feedback!
-Caution:You should not publish apps -using L Developer Preview to the Google Play store.
+Caution: Do not not publish apps +that use the L Developer Preview to the Google Play store.
+ +Note: This document often refers to classes and +methods that do not yet have reference material available on developer.android.com. These API elements are +formatted in {@code code style} in this document (without hyperlinks). For the +preliminary API documentation for these elements, download the preview +reference.
If you have previously published an app for Android, be aware that your app - might be affected by changes in L.
+ might be affected by changes in the upcoming release. + +The 4.4 release introduced a new, experimental Android runtime, ART. Under +4.4, ART was optional, and the default runtime remained Dalvik. With the L Developer Preview, ART is +now the default runtime.
+ +For an overview of ART's new features, see +Introducing +ART. Some of the major new features are:
+ +Most Android apps should just work without change under ART. However, some +techniques that work on Dalvik do not work on ART. For information about the +most important issues, see +Verifying App +Behavior on the Android Runtime (ART). Pay particular attention if:
+ +Notifications will be drawn with dark text atop white (or very light) +
Notifications are drawn with dark text atop white (or very light) backgrounds to match the new material design widgets. Make sure that all your -notifications look right with the new color scheme. You should remove or update -assets and text styles that involve color. The system will automatically invert -action icons in notifications. Use -{@code android.app.Notification.Builder.setColor()} to set an accent color -in a circle behind your {@code Notification.icon} image.
+notifications look right with the new color scheme: -The system will ignore all non-alpha channels in action icons and the main -notification icon, so you should assume that these icons will be alpha-only. -
+If you are currently adding sounds and vibrations to your notifications by using the {@link android.media.Ringtone}, {@link android.media.MediaPlayer}, -or {@link android.os.Vibrator} classes, make sure to remove this code so that -the system can present notifications correctly in Do not disturb mode. You -should use the {@link android.app.Notification.Builder} methods instead to add -sounds and vibration. -
+or {@link android.os.Vibrator} classes, remove this code so that +the system can present notifications correctly in Do Not Disturb mode. +Instead, use the {@link android.app.Notification.Builder} methods instead to add +sounds and vibration.Lockscreens in L will not show transport controls for your +
Lockscreens in the L Developer Preview do not show transport controls for your {@link android.media.RemoteControlClient}. Instead, your app can provide media playback control from the lockscreen through a media notification. This gives your app more control over the presentation of media buttons, while providing a consistent experience for users across the lockscreen and unlocked device.
-You must call {@code Notification.Builder.setVisibility(Notification.VISIBILITY_PUBLIC)} to mark your media notification as safe to reveal, even when the lockscreen is secured -with a PIN, pattern, or password.
+Call {@code +Notification.Builder.setVisibility(Notification.VISIBILITY_PUBLIC)} to mark a +notification as safe to display on the lockscreen (even when the lockscreen is +secured with a PIN, pattern, or password). For more information, see +Lockscreen Notifications.
Notifications now appear in a small floating window if all these conditions -are met: the user’s activity is in fullscreen mode, the screen is on, and the -device is unlocked. If your app implements fullscreen activities, make sure that +are met:
+ +If your app implements fullscreen activities, make sure that these heads-up notifications are presented correctly.
With the introduction of the new document tasks feature in L (see below), -the {@code android.app.ActivityManager.getRecentTasks()} method is now -deprecated to improve user privacy. For backwards -compatibility, it will still return a small subset of its data including the +
With the introduction of the new concurrent documents and activities tasks feature in the upcoming +release (see Concurrent documents and activities in Recents +screen below), +the {@link android.app.ActivityManager#getRecentTasks +ActivityManager.getRecentTasks()} method is now +deprecated to improve user privacy. For backward +compatibility, this method still returns a small subset of its data, including the calling application’s own tasks and possibly some other non-sensitive tasks -such as home. If your app is using this method to retrieve its own tasks, +(such as Home). If your app is using this method to retrieve its own tasks, use {@code android.app.ActivityManager.getAppTasks()} instead to retrieve that information.
@@ -170,11 +230,15 @@ information.The L Developer Preview adds support for the material design style. You can create -material design apps that are visually dynamic and have UI element transitions -which feel natural and delightful to users. This support includes:
+ +The upcoming release 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:
+To learn more about adding material design functionality to your app, see -Material design on Android.
+Material Design.Lockscreens in the L Developer Preview have the ability to present notifications. @@ -194,29 +259,57 @@ content to be shown over a secure lockscreen.
displayed over the secure lockscreen. To control the visibility level, call {@code android.app.Notification.Builder.setVisibility()} and specify one of these values: +publicVersion
-field.The L Developer Preview uses metadata associated with your app notifications -to more intelligently sort your notifications. The metadata you set also -controls how the system presents your app notifications when the user is in Do -not disturb mode. When constructing your notification, you can call the -following methods in {@code android.app.Notification.Builder}:
+The L Developer Preview introduces a new Do Not Disturb mode. When +the user puts the device in Do Not Disturb mode, the device limits +the frequency of the notifications it shows the user (when the user +wants to avoid distractions). The user can +customize the feature in a number of ways, such as:
You should add the appropriate metadata to your app notifications to help +make sure Do Not Disturb mode handles them properly. For example, if +your app is an alarm clock, +you can tag the notification as an alarm so it will wake the user up even if the +device is in Do Not Disturb mode. For more information, see Notifications metadata.
+ +The L Developer Preview uses metadata associated with your app notifications +to sort the notifications more intelligently. The metadata you set also +controls how the system presents your app notifications when the user is in Do +Not Disturb mode. To set the metadata, call the following methods in +{@code android.app.Notification.Builder} when you construct the +notification:
+ +In previous releases, the Recents screen could only display a single task for each app that the user interacted with -most recently. The L Developer Preview allows your app to open additional tasks -for concurrent activities or documents. This feature facilitates multitasking +most recently. The L Developer Preview enables your app to 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. Examples of such concurrent tasks might include web -pages in a browser app, documents in a productivity app, concurrent matches in +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 {@code android.app.ActivityManager.AppTask} class.
To insert a logical break so that the system treats your activity as a new -document, use {@code android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT} when +task, use {@code android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT} when launching the activity with {@link android.app.Activity#startActivity(android.content.Intent) startActivity()}. You can also get this behavior by declaring the <activity> attribute {@code documentLaunchMode="intoExisting"} or {@code ="always"} in your manifest.
You can also mark that a task should be removed from the Recents screen -when all its activities are closed by using {@code android.content.Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS} when starting the root activity for +when all its activities are closed. To do this, use {@code +android.content.Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS} when starting the +root activity for the task. You can also set this behavior for an activity by declaring the <activity> attribute {@code autoRemoveFromRecents=“true”} in your manifest.
To avoid cluttering the Recents screen, you can set the maximum number of -tasks from your app that can appear in the Recents screen through the -<application> attribute {@code android:maxRecent}. The current maximum that can be specified +tasks from your app that can appear in that screen. To do this, set the +<application> +attribute {@code android:maxRecent}. The current maximum that can be specified is 100 tasks per user.
Beginning in the L Developer Preview, users can more easily switch between -all input method editors (IME) supported by the platform. Performing the designated +all input +method editors (IME) supported by the platform. Performing the designated switching action (usually touching a Globe icon on the soft keyboard) will cycle among all such IMEs. This change takes place in -{@code android.view.inputmethod.InputMethodManager.shouldOfferSwitchingToNextInputMethod()}.
+{@link android.view.inputmethod.InputMethodManager#shouldOfferSwitchingToNextInputMethod +InputMethodManager.shouldOfferSwitchingToNextInputMethod()}. -In addition, the framework will now check whether the next IME includes a -switching mechanism at all, thus supporting switching to the IME after it. An +
In addition, the framework now checks whether the next IME includes a +switching mechanism at all (and, thus, whether that IME supports switching to +the IME after it). An IME with a switching mechanism will not cycle to an IME without one. This change takes place in -{@code android.view.inputmethod.InputMethodManager.switchToNextInputMethod()}. +{@link android.view.inputmethod.InputMethodManager#switchToNextInputMethod +InputMethodManager.switchToNextInputMethod}.
To see an example of how to use the updated IME-switching APIs, refer to the updated soft-keyboard implementation sample in this release.
@@ -314,17 +416,20 @@ ES 3.1. Key new functionality provided in OpenGL ES 3.1 includes: </manifest> -For more information about using OpenGL ES, including how to check the device’s supported OpenGL ES version at runtime, see the OpenGL ES API guide.
+For more information about using OpenGL ES, including how to check the device’s supported OpenGL ES version at runtime, see the OpenGL ES API guide.
The L Developer Preview introduces the new {@code 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 {@code CameraManager.getCameraIdList()} and connect to a specific device with {@code CameraManager.openCamera()}. To start capturing images, you -need to create a {@code CameraCaptureSession} and specify the -{@link android.view.Surface} objects to send the captured images. The {@code CameraCaptureSession} can be configured to take single shots or multiple images -in a burst.
+API to facilitate fine-grain photo capture and image processing. You can now +programmatically access the camera devices available to the system with {@code +CameraManager.getCameraIdList()} and connect to a specific device with {@code +CameraManager.openCamera()}. To start capturing images, create a {@code +CameraCaptureSession} and specify the {@link android.view.Surface} objects for +the captured images. The {@code CameraCaptureSession} can be configured to take +single shots or multiple images in a burst.To be notified when new images are captured, implement the {@code CameraCaptureSession.CaptureListener()} interface and set it in your @@ -334,16 +439,17 @@ capture request. Now when the system completes the image capture request, your {@code CaptureResult}.
This release includes the following changes for - {@code android.media.AudioTrack}:
+This release includes the following changes to + {@link android.media.AudioTrack}:
You can now build your own media controller app with the new {@code android.media.session.MediaController} class, which provides simplified transport controls APIs that replace those in -{@code android.media.RemoteControlClient}. The {@code MediaController} class -allows thread-safe control of playback from a non UI process, making it easier +{@link android.media.RemoteControlClient}. The {@code MediaController} class +allows thread-safe control of playback from a non-UI process, making it easier to control your media playback service from your app’s user interface.
You can also create multiple controllers to send playback commands, @@ -362,14 +468,16 @@ media keys, and other events to the same ongoing call {@code MediaSession.getSessionToken()} to request an access token in order for your app to interact with the session.
-Send transport commands such as "play", "stop", "skip", and +
You can now send transport commands such as "play", "stop", "skip", and "set rating" by using {@code MediaController.TransportControls}. To handle -in-bound media transport commands from controllers attached to the session, you -should override the callback methods in +in-bound media transport commands from controllers attached to the session, +override the callback methods in {@code MediaSession.TransportControlsCallback}.
You can also create rich notifications that allow playback control tied to a -media session with the new {@code android.app.Notification.MediaStyle} class.
+media session with the new {@code android.app.Notification.MediaStyle} class. By +using the new notification and media APIs, you will ensure that the System UI +knows about your playback and can extract and show album art.To get the absolute paths to directories on external storage devices where -applications can store media files, call the -{@code android.content.Context.getExternalMediaDirs()} method. No additional +applications can store media files, call the new +{@code android.content.Context.getExternalMediaDirs()} method. No +additional permissions are needed by your app to read or write to the returned paths. -External storage devices here are those considered by the system to be a +In this context, "external storage devices" are those devices which the system +considers to be a permanent part of the device, and includes emulated external storage and physical media slots such as SD cards in battery compartments.
If you want to access a document in an existing directory, call the -{@code android.provider.DocumentsContract.buildDocumentViaUri()} method and pass -in a Uri representing the path to the parent directory and the target document -ID. The method returns a new {@link android.net.Uri} with which your app can +{@code android.provider.DocumentsContract.buildDocumentViaUri()} method. +Pass the method a URI representing the path to the parent directory, and the +target document +ID. The method returns a new {@link android.net.Uri} which your app can use to write media content with {@code DocumentsContract.createDocument()}.
The L Developer Preview provides new multi-networking APIs for your app to +
The L Developer Preview provides new multi-networking APIs. These let your app dynamically scan for available networks with specific capabilities, and establish a connection to them. This is useful when your app requires a specialized network, such as an SUPL, MMS, or carrier-billing network, or if you want to send data using a particular type of transport protocol.
-To select and connect to a network dynamically from your app, first -instantiate a {@code android.net.ConnectivityManager}. Next, create a -{@code android.net.NetworkRequest} to specify the network features and transport -type your app is interested in. To start scanning for suitable networks, call -{@code ConnectivityManager.requestNetwork()} or -{@code ConnectivityManager.registerNetworkCallback(), and pass in the -{@code NetworkRequest} object and an implementation of -{@code ConnectivityManager.NetworkCallbackListener}.
+To select and connect to a network dynamically from your app follow these +steps:
+ +When the system detects a suitable network, it connects to the network and invokes the {@code NetworkCallbackListener.onAvailable()} callback. You can use the {@code android.net.Network} object from the callback to get additional -information about the network, or to establish a socket connection.
+information about the network, or to direct traffic to use the selected +network.Android 4.3 introduced platform support for Bluetooth Low Energy (BLE) in the central role. In the L Developer Preview, an Android device can now -act as a Bluetooth LE peripheral device and make its presence known to +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 BLE device.
@@ -429,16 +549,19 @@ BLE device. You must add the {@code android.permission.BLUETOOTH_ADMIN} permission in your manifest in order for your app to use the new advertising and scanning features. -To begin Bluetooth LE advertising so that other devices can discover the -device running your app, call {@code android.bluetooth.le.BluetoothAdvertiser.startAdvisertising()} and pass in an implementation of the -{@code android.bluetooth.le.AdvertiseCallback} class to report the success -or failure of the advertising operation.
+To begin Bluetooth LE advertising so that other devices can discover +your app, call {@code android.bluetooth.le.BluetoothAdvertiser.startAdvisertising()} +and pass in an implementation of the +{@code android.bluetooth.le.AdvertiseCallback} class. The callback object +receives a report of the success or failure of the advertising operation.
-Conversely, if you want to scan for Bluetooth LE devices nearby, call -{@code android.bluetooth.le.BluetoothLeScanner.startScan()} and pass in an +
The L Developer Preview introduces the {@code +android.bluetooth.le.ScanFilter} class so that your app can scan for only the +specific types of devices it is interested in. To begin scanning for Bluetooth +LE devices, call {@code android.bluetooth.le.BluetoothLeScanner.startScan()} and +pass in a list of filters. In the method call, you must also provide an implementation of {@code android.bluetooth.le.ScanCallback} to report if a -Bluetooth LE advertisement is found. Optionally, you can pass in filters to scan -for a specific type of device.
+Bluetooth LE advertisement is found.The L Developer Preview adds these enhancements to enable wider and more @@ -446,13 +569,12 @@ flexible use of NFC:
The L Developer Preview provides a new {@code android.app.job.JobScheduler} API that lets you optimize battery life by defining jobs for the system to run -asynchronously at a later time, such as when the device is charging. This is -useful when you want to defer non user-facing units of work, have application -code that accesses the network, or want to run a number of tasks as a batch on -a regular schedule.
+asynchronously at a later time or under specified conditions (such as when the +device is charging). This is useful in such situations as: +A {@code android.app.job.JobInfo} object encapsulates such a unit of work, -and provides an exact description of the criteria you are scheduling.
+A unit of work is encapsulated by a {@code android.app.job.JobInfo} object. +This object provides an exact description of the criteria to be used for +scheduling.
Use the {@code android.app.job.JobInfo.Builder} to configure how the scheduled task should run. You can schedule the task to run under specific -conditions such as only while the device is charging, when connected to an -unmetered network, or when the system deems the device is idle.
+conditions, such as: + +For example, you can add code like this to run your task on an unmetered network:
@@ -513,23 +648,33 @@ statistical data about battery usage on a device, organized by unique user IDUse the {@code --help} option to learn about the various options for -tailoring the output. For example, to run the tool to print battery usage -statistics since the device was last charged for a given app package, run this +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+$ adb shell dumpsys batterystats --charged <package-name>
The Battery Historian tool ({@code historian.par}) analyzes L-based Android -bug reports and creates an HTML visualization of power-related events. It can -also visualize power consumption data from a power monitor, and will attempt to -map power usage to the wakelocks seen. You can find the Battery Historian tool +
The Battery Historian tool ({@code historian.par}) analyzes Android +bug reports from the L Developer Preview and creates an HTML visualization of +power-related events. It can +also visualize power consumption data from a power monitor, and attempts to +map power usage to the wake locks seen. You can find the Battery Historian tool in {@code <sdk>/tools}.
-For best results, you should first enable full wakelock reporting to allow
+
+
+ Figure 1.HTML visualization generated by the Battery + Historian tool. +
+ +For best results, you should first enable full wake lock reporting, to allow the Battery Historian tool to monitor uninterrupted over an extended period of time:
@@ -548,93 +693,70 @@ $ historian.par [-p powerfile] bugreport.txt > out.html
You can use the {@code android.os.BatteryManager} API to obtain power -consumption information based on the battery fuel gauge included in Android -phones and tablets. This is useful in cases when it is not convenient to -connect external measurement equipment to the Android device.
-To retrieve the battery properties, call {@code BatteryManager.getIntProperty()} -or {@code BatteryManager.getLongProperty()}. The properties available, the -exact resolution of the values of each, and other characteristics such as -update frequency depend on the particular device being tested.
- -The following properties can be inspected on all Android devices:
- -| Property | -Description | -
|---|---|
| {@code BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER} | -Remaining battery capacity in microampere-hours. | -
| {@code BatteryManager.BATTERY_PROPERTY_CURRENT_NOW} | -Instantaneous battery current in microamperes. | -
| {@code BatteryManager.BATTERY_PROPERTY_CURRENT_AVERAGE} | -Average battery current in microamperes | -
| {@code BatteryManager.BATTERY_PROPERTY_CAPACITY} | -Remaining battery capacity as an integer percentage. | -
| {@code BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER} | -Remaining energy in nanowatt-hours. | -
+ + Figure 2. Launcher screen showing managed apps (marked with + a lock badge) +
+The L Developer Preview provides new functionality for running apps within an enterprise environment:
To start the manged provisioning process, send -{@code ACTION_PROVISION_MANAGED_PROFILE} in an {@link android.content.Intent}. A -user may be associated with more than one managed profile. To get a list of the -managed profiles associated with the user, call -{@code android.os.UserManager.getUserProfiles()}.
+To start the managed provisioning process, send {@code +ACTION_PROVISION_MANAGED_PROFILE} in an {@link android.content.Intent}. If the +call is successful, the system triggers the {@code +android.app.admin.DeviceAdminReceiver. onProfileProvisioningComplete()} callback. +You can then call {@code app.admin.DevicePolicyManager. setProfileEnabled()} to +set this profile to the enabled state.
+ +A user may be associated with more than one managed profile. To get a list of +the managed profiles associated with the user, call +{@code android.os.UserManager. getUserProfiles()}.
Once a managed profile is created for a user, apps that are managed by the device administrator will appear alongside non-managed apps in the user’s -Launcher, Recent apps screen, and notifications. A device policy management app -can make the managed apps visually prominent by appending a “work” badge to the -icon drawable with {@code android.os.UserManager.getBadgeDrawableForUser()}.
+Launcher, Recent apps screen, and notifications. -If you are developing a Launcher app, you can use the new {@code android.content.pm.LauncherApps} class to get a list of launchable activities for the current user -and any associated managed profiles.
+If you are developing a Launcher app, you can use the new {@code +android.content.pm.LauncherApps} class to get a list of launchable activities +for the current user and any associated managed profiles. Your Launcher can make +the managed apps visually prominent by appending a “work” badge to the icon +drawable with {@code android.os.UserManager.getBadgeDrawableForUser()}.
You can now render PDF document pages into bitmap images for printing by using the new {@code android.graphics.pdf.PdfRenderer} class. You must specify a -{@code ParcelFileDescriptor} that is seekable (that is, the file can be randomly +{@link android.os.ParcelFileDescriptor} that is seekable (that is, the content can be randomly accessed) on which the system writes the the printable content. Your app can obtain a page for rendering with {@code openPage()}, then call {@code render()} to turn the opened {@code PdfRenderer.Page} into a bitmap. You can also set -additional parameters if you only wan to convert a portion of the document into +additional parameters if you only want to convert a portion of the document into a bitmap image (for example, to implement tile rendering in order to zoom in on the document).
The L Developer Preview adds the following support for testing and accessibility:
@@ -644,44 +766,45 @@ and {@code android.app.UiAutomation.getWindowContentFrameStats()} methods to capture frame statistics for window animations and content. This lets you write instrumentation tests to evaluate if the app under test is rendering frames at a sufficient refresh frequency to provide a smooth user experience. +The following values are now supported in the {@code <uses-feature>} element so you +
The following values are now supported in the {@code <uses-feature>} element, so you can ensure that your app is installed only on devices that provide the features your app needs.
<uses-feature android:name="android.software.leanback"
android:required="true" />
--<uses-feature android:name="android.software.managedprofiles" - android:required="true" /> --
<uses-feature android:name="android.software.webview"
android:required="true" />
diff --git a/docs/html/preview/images/battery_historian.png b/docs/html/preview/images/battery_historian.png
new file mode 100644
index 0000000000000..5b0db74cb87eb
Binary files /dev/null and b/docs/html/preview/images/battery_historian.png differ
diff --git a/docs/html/preview/images/battery_historian@2x.png b/docs/html/preview/images/battery_historian@2x.png
new file mode 100644
index 0000000000000..dbb5d5eb5ff8b
Binary files /dev/null and b/docs/html/preview/images/battery_historian@2x.png differ
diff --git a/docs/html/preview/images/managed_apps_launcher.png b/docs/html/preview/images/managed_apps_launcher.png
new file mode 100644
index 0000000000000..983d90460353d
Binary files /dev/null and b/docs/html/preview/images/managed_apps_launcher.png differ
diff --git a/docs/html/preview/images/managed_apps_launcher@2.png b/docs/html/preview/images/managed_apps_launcher@2.png
new file mode 100644
index 0000000000000..d298fd2deb287
Binary files /dev/null and b/docs/html/preview/images/managed_apps_launcher@2.png differ