blob: cf594dc61c8df719ca8c7a9bede3b539d4ca381f [file] [log] [blame]
Robert Lyc8590ff2014-06-20 09:33:39 -07001page.title=API Overview
Robert Ly20555292014-06-13 23:28:19 -07002excludeFromSuggestions=true
3sdk.platform.apiLevel=20
4@jd:body
5
6
7<div id="qv-wrapper">
8<div id="qv">
9
10<h2>In this document
11 <a href="#" onclick="hideNestedItems('#toc44',this);return false;" class="header-toggle">
12 <span class="more">show more</span>
13 <span class="less" style="display:none">show less</span></a></h2>
14
15<ol id="toc44" class="hide-nested">
16 <li><a href="#Behaviors">Important Behavior Changes</a>
17 <ol>
Andrew Solovay68990cf2014-06-15 20:26:07 -070018 <li><a href="#ART">New Android Runtime (ART)</a></li>
Robert Ly20555292014-06-13 23:28:19 -070019 <li><a href="#BehaviorNotifications">If your app implements notifications...</a></li>
Andrew Solovay68990cf2014-06-15 20:26:07 -070020 <li><a href="#BehaviorMediaControl">If your app uses RemoteControlClient...</a></li>
Quddus Chongaa9d7782014-06-19 16:16:10 -070021<li><a href="#BehaviorGetRecentTasks">If your app uses ActivityManager.getRecentTasks()...</a></li>
Robert Ly20555292014-06-13 23:28:19 -070022 </ol>
23 </li>
24 <li><a href="#UI">User Interface</a>
25 <ol>
26 <li><a href="#MaterialDesign">Material design support</a></li>
27 <li><a href="#LockscreenNotifications">Lockscreen notifications</a></li>
28 <li><a href="#NotificationsMetadata">Notifications metadata</a></li>
Andrew Solovay68990cf2014-06-15 20:26:07 -070029 <li><a href="#Recents">Concurrent documents and activities in the Recents screen</a></li>
Robert Ly20555292014-06-13 23:28:19 -070030 <li><a href="#WebView">WebView updates</a></li>
31 </ol>
32 </li>
Quddus Chong26aec762014-06-24 10:14:12 -070033 <li><a href="#Graphics">Graphics</a>
Robert Ly20555292014-06-13 23:28:19 -070034 <ol>
35 <li><a href="#OpenGLES-3-1">Support for OpenGL ES 3.1</a></li>
Quddus Chonga2cc6cc2014-06-23 12:34:59 -070036 <li><a href="#AndroidExtensionPack">Android Extension Pack</a></li>
Robert Ly20555292014-06-13 23:28:19 -070037 </ol>
38 </li>
39 <li><a href="#Multimedia">Multimedia</a>
40 <ol>
Quddus Chonga2cc6cc2014-06-23 12:34:59 -070041 <li><a href="#Camera-v2">Camera API for advanced camera capabilities</a></li>
Robert Ly20555292014-06-13 23:28:19 -070042 <li><a href="#AudioPlayback">Audio playback</a></li>
43 <li><a href="#MediaPlaybackControl">Media playback control</a></li>
44 </ol>
45 </li>
46 <li><a href="#Storage">Storage</a>
47 <ol>
48 <li><a href="#DirectorySelection">Directory selection</a></li>
49 </ol>
50 </li>
51 <li><a href="#Wireless">Wireless and Connectivity</a>
52 <ol>
Quddus Chonga2cc6cc2014-06-23 12:34:59 -070053 <li><a href="#Multinetwork">Multiple network connections</a></li>
Robert Ly20555292014-06-13 23:28:19 -070054 <li><a href="#BluetoothBroadcasting">Bluetooth broadcasting</a></li>
Andrew Solovay68990cf2014-06-15 20:26:07 -070055 <li><a href="#NFCEnhancements">NFC enhancements</a></li>
Robert Ly20555292014-06-13 23:28:19 -070056 </ol>
57 </li>
58 <li><a href="#Power">Power Efficiency</a>
59 <ol>
60 <li><a href="#JobScheduler">Scheduling Jobs</a></li>
Quddus Chong17305642014-06-18 12:19:06 -070061 <li><a href="#PowerMeasurementTools">Developer tools for power measurement</a>
Robert Ly20555292014-06-13 23:28:19 -070062 </ol>
63 </li>
64 <li><a href="#Enterprise">Enterprise</a>
65 <ol>
66 <li><a href="#ManagedProvisioning">Managed provisioning</a></li>
Quddus Chongaa9d7782014-06-19 16:16:10 -070067 <li><a href="#TaskLocking">Task locking</a></li>
Robert Ly20555292014-06-13 23:28:19 -070068 </ol>
69 </li>
70 <li><a href="#Printing">Printing Framework</a>
71 <ol>
Andrew Solovay68990cf2014-06-15 20:26:07 -070072 <li><a href="#PDFRender">Render PDF as bitmap</a></li>
Robert Ly20555292014-06-13 23:28:19 -070073 </ol>
74 </li>
75 <li><a href="#TestingA11y">Testing &amp; Accessibility</a>
76 <ol>
77 <li><a href="#TestingA11yImprovements">Testing and accessibility improvements</a></li>
78 </ol>
79 </li>
Quddus Chong26aec762014-06-24 10:14:12 -070080 <li><a href="#IME">IME</a>
81 <ol>
82 <li><a href="#Switching">Easier switching between input languages</a></li>
83 </ol>
84 </li>
Robert Ly20555292014-06-13 23:28:19 -070085 <li><a href="#Manifest">Manifest Declarations</a>
86 <ol>
87 <li><a href="#ManifestFeatures">Declarable required features</a></li>
Robert Ly20555292014-06-13 23:28:19 -070088 </ol>
89 </li>
90</ol>
91
Robert Ly20555292014-06-13 23:28:19 -070092</div>
93</div>
94
Quddus Chong17305642014-06-18 12:19:06 -070095<p>The L Developer Preview gives you an advance look at the upcoming release
96for the Android platform, which offers new features for users and app
97developers. This document provides an introduction to the most notable APIs.</p>
Robert Ly20555292014-06-13 23:28:19 -070098
Quddus Chong17305642014-06-18 12:19:06 -070099<p>The L Developer Preview is intended for <strong>developer early
100adopters</strong> and <strong>testers</strong>. If you are interested in
101influencing the direction of the Android framework,
102<a href="{@docRoot}preview/setup-sdk.html">give the L Developer Preview a
103try</a> and send us your feedback!</p>
Robert Ly20555292014-06-13 23:28:19 -0700104
Andrew Solovay68990cf2014-06-15 20:26:07 -0700105<p class="caution"><strong>Caution:</strong> Do not not publish apps
106that use the L Developer Preview to the Google Play store.</p>
107
108<p class="note"><strong>Note:</strong> This document often refers to classes and
109methods that do not yet have reference material available on <a
110href="{@docRoot}">developer.android.com</a>. These API elements are
111formatted in {@code code style} in this document (without hyperlinks). For the
112preliminary API documentation for these elements, download the <a
Robert Ly2f48339b2014-06-26 11:36:23 -0700113href="http://storage.googleapis.com/androiddevelopers/preview/l-developer-preview-reference.zip">preview
Andrew Solovay68990cf2014-06-15 20:26:07 -0700114reference</a>.</p>
Robert Ly20555292014-06-13 23:28:19 -0700115
116<h2 id="Behaviors">Important Behavior Changes</h2>
117
118<p>If you have previously published an app for Android, be aware that your app
Andrew Solovay68990cf2014-06-15 20:26:07 -0700119 might be affected by changes in the upcoming release.</p>
120
121<h3 id="ART">New Android Runtime (ART)</h3>
122
123<p>The 4.4 release introduced a new, experimental Android runtime, ART. Under
Quddus Chong17305642014-06-18 12:19:06 -07001244.4, ART was optional, and the default runtime remained Dalvik. With the L
125Developer Preview, ART is now the default runtime.</p>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700126
127<p>For an overview of ART's new features, see
128<a href="https://source.android.com/devices/tech/dalvik/art.html">Introducing
129ART</a>. Some of the major new features are:</p>
130
131<ul>
132 <li>Ahead-of-Time (AOT) compilation</li>
133 <li>Improved garbage collection (GC)</li>
134 <li>Improved debugging support</li>
135</ul>
136
137<p>Most Android apps should just work without change under ART. However, some
138techniques that work on Dalvik do not work on ART. For information about the
139most important issues, see
140<a href="{@docRoot}guide/practices/verifying-apps-art.html">Verifying App
141Behavior on the Android Runtime (ART)</a>. Pay particular attention if:</p>
142
143<ul>
144 <li>Your app uses Java Native Interface (JNI) to run C/C++ code.</li>
145 <li>You use development tools that generate non-standard code (such as some
146 obfuscators).</li>
147 <li>You use techniques that are incompatible with compacting garbage
148 collection. (ART does not currently implement compacting GC, but
149 compacting GC is under development in the Android Open-Source
150 Project.)</li>
151</ul>
Robert Ly20555292014-06-13 23:28:19 -0700152
153<h3 id="BehaviorNotifications">If your app implements notifications...</h3>
154
Andrew Solovay68990cf2014-06-15 20:26:07 -0700155<p>Notifications are drawn with dark text atop white (or very light)
Robert Ly20555292014-06-13 23:28:19 -0700156backgrounds to match the new material design widgets. Make sure that all your
Andrew Solovay68990cf2014-06-15 20:26:07 -0700157notifications look right with the new color scheme:</p>
Robert Ly20555292014-06-13 23:28:19 -0700158
Quddus Chongaa9d7782014-06-19 16:16:10 -0700159<div class="figure" style="width:320px">
Quddus Chong17305642014-06-18 12:19:06 -0700160 <img src="images/hun-example.png"
161 srcset="images/hun-example@2x.png 2x"
Quddus Chongaa9d7782014-06-19 16:16:10 -0700162 alt="" width="320" height="541" id="figure1" />
Quddus Chong17305642014-06-18 12:19:06 -0700163 <p class="img-caption">
164 <strong>Figure 1.</strong> Fullscreen activity showing a heads-up notification
165 </p>
166</div>
167
Andrew Solovay68990cf2014-06-15 20:26:07 -0700168<ul>
169
170 <li>Update or remove assets that involve color.</li>
171
172 <li>The system automatically inverts action icons in notifications. Use
Quddus Chongaa9d7782014-06-19 16:16:10 -0700173 {@code android.app.Notification. Builder.setColor()} to set an accent color
Andrew Solovay68990cf2014-06-15 20:26:07 -0700174 in a circle behind your {@link android.app.Notification#icon} image.</li>
175
176 <li>The system ignores all non-alpha channels in action icons and the main
177 notification icon. You should assume that these icons are alpha-only.</li>
178
179</ul>
Robert Ly20555292014-06-13 23:28:19 -0700180
181<p>If you are currently adding sounds and vibrations to your notifications by
182using the {@link android.media.Ringtone}, {@link android.media.MediaPlayer},
Andrew Solovay68990cf2014-06-15 20:26:07 -0700183or {@link android.os.Vibrator} classes, remove this code so that
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700184the system can present notifications correctly in Do
185not Disturb mode. Instead, use the {@link android.app.Notification.Builder}
Quddus Chongaa9d7782014-06-19 16:16:10 -0700186methods instead to add sounds and vibration.</p>
Quddus Chong17305642014-06-18 12:19:06 -0700187
188<p>Notifications now appear in a small floating window
189(also called a <em>heads-up notification</em>) when the device is active
190(that is, the device is unlocked and its screen is on). These notifications
191appear similar to the compact form of your notification, except that the
192heads-up notification also shows action buttons. Users can act on, or dismiss,
193a heads-up notification without leaving the current app.</p>
194
195<p>Examples of conditions that may trigger heads-up notifications include:</p>
196
197<ul>
198 <li>The user's activity is in fullscreen mode (the app uses
199{@link android.app.Notification#fullScreenIntent}), or</li>
200 <li>The notification has high priority and uses ringtones or
201 vibrations</li>
202</ul>
203
204<p>If your app implements notifications under those scenarios, make sure that
205heads-up notifications are presented correctly.</p>
Robert Ly20555292014-06-13 23:28:19 -0700206
207<h3 id="BehaviorMediaControl">If your app uses RemoteControlClient...</h3>
208
Quddus Chong17305642014-06-18 12:19:06 -0700209<p>Lockscreens in the L Developer Preview do not show transport controls for
210your {@link android.media.RemoteControlClient}. Instead, your app can provide
211media playback control from the lockscreen through a notification. This
Robert Ly20555292014-06-13 23:28:19 -0700212gives your app more control over the presentation of media buttons, while
213providing a consistent experience for users across the lockscreen and
Quddus Chongd50a6f82014-06-15 12:13:18 -0700214unlocked device.</p>
Robert Ly20555292014-06-13 23:28:19 -0700215
Quddus Chongaa9d7782014-06-19 16:16:10 -0700216<p>The L Developer Preview introduces a new
217{@code android.app.Notification.MediaStyle} template which is recommended for
218this purpose. {@code MediaStyle} converts notification actions that you added
219with
220{@link android.app.Notification.Builder#addAction(int, java.lang.CharSequence,
221 android.app.PendingIntent)
222Notification.Builder.addAction()} into compact buttons embedded in your app's
223media playback notifications.</p>
Quddus Chong17305642014-06-18 12:19:06 -0700224
225<p>If you are using the new
Quddus Chongaa9d7782014-06-19 16:16:10 -0700226{@code android.media.session.MediaSession} class
227(see <a href="#MediaPlaybackControl">Media Playback Control</a> below), attach
228your session token with {@code Notification.MediaStyle.setMediaToken()} to
229inform the system that this notification controls an ongoing media session.</p>
Quddus Chong17305642014-06-18 12:19:06 -0700230
Andrew Solovay68990cf2014-06-15 20:26:07 -0700231<p>Call {@code
232Notification.Builder.setVisibility(Notification.VISIBILITY_PUBLIC)} to mark a
Quddus Chongaa9d7782014-06-19 16:16:10 -0700233notification as safe to show atop any lockscreen (secure or otherwise). For more
234information, see <a href="#LockscreenNotifications">Lockscreen Notifications</a>.</p>
Robert Ly20555292014-06-13 23:28:19 -0700235
Robert Ly20555292014-06-13 23:28:19 -0700236<h3 id="BehaviorGetRecentTasks">If your app uses ActivityManager.getRecentTasks()...</h3>
237
Quddus Chongaa9d7782014-06-19 16:16:10 -0700238<p>With the introduction of the new <em>concurrent documents and activities
239tasks</em> feature in the upcoming release (see <a href="#Recents">Concurrent
240documents and activities in Recents screen</a> below),
Andrew Solovay68990cf2014-06-15 20:26:07 -0700241the {@link android.app.ActivityManager#getRecentTasks
Quddus Chongaa9d7782014-06-19 16:16:10 -0700242ActivityManager.getRecentTasks()} method is now deprecated to improve user
243privacy. For backward compatibility, this method still returns a small subset of
244its data, including the calling application’s own tasks and possibly some other
245non-sensitive tasks (such as Home). If your app is using this method to retrieve
246its own tasks, use {@code android.app.ActivityManager.getAppTasks()} instead to
247retrieve that information.</p>
Robert Ly20555292014-06-13 23:28:19 -0700248
249<h2 id="UI">User Interface</h2>
250
251<h3 id="MaterialDesign">Material design support</h3>
252
Andrew Solovay68990cf2014-06-15 20:26:07 -0700253<p>The upcoming release adds support for Android's new <em>material</em> design
Quddus Chongaa9d7782014-06-19 16:16:10 -0700254style. You can create apps with material design that are visually dynamic and
255have UI element transitions that feel natural to users. This support includes:</p>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700256
Robert Ly20555292014-06-13 23:28:19 -0700257<ul>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700258
259 <li>The material theme</li>
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700260 <li>View shadows</li>
261 <li>The {@code RecyclerView} widget</li>
262 <li>Drawable animation and styling effects</li>
263 <li>Material design animation and activity transition effects</li>
264 <li>Animators for view properties based on the state of a view</li>
265 <li>Customizable UI widgets and app bars with color palettes that you control</li>
Robert Ly20555292014-06-13 23:28:19 -0700266</ul>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700267
Robert Ly20555292014-06-13 23:28:19 -0700268<p>To learn more about adding material design functionality to your app, see
Andrew Solovay68990cf2014-06-15 20:26:07 -0700269<a href="{@docRoot}preview/material/index.html">Material Design</a>.</p>
Robert Ly20555292014-06-13 23:28:19 -0700270
271<h3 id="LockscreenNotifications">Lockscreen notifications</h3>
Quddus Chongaa9d7782014-06-19 16:16:10 -0700272<p>Lockscreens in the L Developer Preview have the ability to present
273notifications. Users can choose via <em>Settings</em> whether to allow
274sensitive notification content to be shown over a secure lockscreen.</p>
Robert Ly20555292014-06-13 23:28:19 -0700275
276<p>Your app can control the level of detail visible when its notifications are
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700277displayed over the secure lockscreen. To control the visibility level, call
Robert Ly20555292014-06-13 23:28:19 -0700278{@code android.app.Notification.Builder.setVisibility()} and specify one of these
279values:</p>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700280
Robert Ly20555292014-06-13 23:28:19 -0700281<ul>
282<li>{@code VISIBILITY_PRIVATE}. Shows basic information, such as the
Quddus Chong17305642014-06-18 12:19:06 -0700283notification’s icon, but hides the notification’s full content.</li>
284<li>{@code VISIBILITY_PUBLIC}. Shows the notification’s full content.</li>
285<li>{@code VISIBILITY_SECRET}. Shows nothing, excluding even the
286notification’s icon.</li>
Robert Ly20555292014-06-13 23:28:19 -0700287</ul>
288
Quddus Chong17305642014-06-18 12:19:06 -0700289<p>When {@code VISIBILITY_PRIVATE} is set, you can also provide a redacted
290version of the notification content that hides personal details. For example,
Quddus Chongaa9d7782014-06-19 16:16:10 -0700291an SMS app might display a notification that shows "You have 3 new text messages."
292but hides the message content and senders. To provide this alternative
293notification, first create the replacement notification using
294{@link android.app.Notification.Builder}. When you create the private
295notification object, attach the replacement notification to it through the
296{@code Notification.Builder.setPublicVersion()} method.</p>
Quddus Chong17305642014-06-18 12:19:06 -0700297
Andrew Solovay68990cf2014-06-15 20:26:07 -0700298<h3 id="NotificationsMetadata">Notifications metadata</h3>
299<p>The L Developer Preview uses metadata associated with your app notifications
Quddus Chong26aec762014-06-24 10:14:12 -0700300to sort the notifications more intelligently. To set the metadata, call the
301following methods in {@code android.app.Notification.Builder} when you
302construct the notification:</p>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700303
304<ul>
305<li>{@code setCategory()}. Depending on the message category, this tells
306the system how to handle your app notifications when the device is
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700307in <em>Do not Disturb</em> mode (for example, if your notification represents an
Andrew Solovay68990cf2014-06-15 20:26:07 -0700308incoming call, instant message, or alarm).
Robert Ly20555292014-06-13 23:28:19 -0700309<li>{@code setPriority()}. Notifications with the priority field set to
310{@code PRIORITY_MAX} or {@code PRIORITY_HIGH} will appear in a small floating
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700311window if the notification also has sound or vibration.</li>
Robert Ly20555292014-06-13 23:28:19 -0700312<li>{@code addPerson()}. Allows you to add a list of people to a notification.
313Your app can use this to signal to the system that it should group together
314notifications from the specified people, or rank notifications from these
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700315people as being more important.</li>
Robert Ly20555292014-06-13 23:28:19 -0700316</ul>
317
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700318<h3 id="Recents">Concurrent documents and activities in the Recents screen</h3>
Robert Ly20555292014-06-13 23:28:19 -0700319
320<p>In previous releases, the
321<a href="{@docRoot}design/get-started/ui-overview.html">Recents screen</a>
322could only display a single task for each app that the user interacted with
Quddus Chong26aec762014-06-24 10:14:12 -0700323most recently. Now your app can open more tasks as
Andrew Solovay68990cf2014-06-15 20:26:07 -0700324needed for additional concurrent activities for documents.
Quddus Chong26aec762014-06-24 10:14:12 -0700325This feature facilitates multitasking by letting users quickly switch between
326individual activities and documents from the Recents screen, with a consistent
327switching experience across all apps.
Andrew Solovay68990cf2014-06-15 20:26:07 -0700328Examples of such concurrent tasks might include open tabs in a web
329browser app, documents in a productivity app, concurrent matches in
Robert Ly20555292014-06-13 23:28:19 -0700330a game, or chats in a messaging app. Your app can manage its tasks
331through the {@code android.app.ActivityManager.AppTask} class.</p>
332
333<p>To insert a logical break so that the system treats your activity as a new
Andrew Solovay68990cf2014-06-15 20:26:07 -0700334task, use {@code android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT} when
Quddus Chongaa9d7782014-06-19 16:16:10 -0700335launching the activity with {@link android.app.Activity#startActivity(android.content.Intent)
336startActivity()}. You can also get this behavior by declaring the
Robert Ly20555292014-06-13 23:28:19 -0700337<a href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a>
338attribute {@code documentLaunchMode="intoExisting"} or {@code ="always"} in your
339manifest.</p>
340
341<p>You can also mark that a task should be removed from the Recents screen
Andrew Solovay68990cf2014-06-15 20:26:07 -0700342when all its activities are closed. To do this, use {@code
343android.content.Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS} when starting the
344root activity for
Robert Ly20555292014-06-13 23:28:19 -0700345the task. You can also set this behavior for an activity by declaring the
346<a href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a>
347attribute {@code autoRemoveFromRecents=“true”} in your manifest.</p>
348
349<p>To avoid cluttering the Recents screen, you can set the maximum number of
Andrew Solovay68990cf2014-06-15 20:26:07 -0700350tasks from your app that can appear in that screen. To do this, set the
351<a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a>
352attribute {@code android:maxRecent}. The current maximum that can be specified
Robert Ly20555292014-06-13 23:28:19 -0700353is 100 tasks per user.</a></p>
354
355<h3 id="WebView">WebView updates</h3>
356<p>The L Developer Preview updates the {@link android.webkit.WebView}
357implementation to Chromium M36, bringing security and stability enhancements,
358as well as bug fixes. The default user-agent string for a
359{@link android.webkit.WebView} running on the L Developer Preview has
360been updated to incorporate 36.0.0.0 as the version number.</p>
361
362<p>Additionally, this release brings support for the
Quddus Chong26aec762014-06-24 10:14:12 -0700363<a href="http://webaudio.github.io/web-audio-api/" class="external-link">WebAudio</a>,
364<a href="https://www.khronos.org/webgl/" class="external-link">WebGL</a>, and
365<a href="http://www.webrtc.org/" class="external-link">WebRTC</a> open standards. To learn more about
366the new features included in this release, see <a href="https://developer.chrome.com/multidevice/webview/overview" class="external-link">WebView for Android</a>.</p>
Robert Ly20555292014-06-13 23:28:19 -0700367
Quddus Chong26aec762014-06-24 10:14:12 -0700368<h2 id="Graphics">Graphics</h2>
Robert Ly20555292014-06-13 23:28:19 -0700369
370<h3 id="OpenGLES-3-1">Support for OpenGL ES 3.1</h3>
371<p>The L Developer Preview adds Java interfaces and native support for OpenGL
372ES 3.1. Key new functionality provided in OpenGL ES 3.1 includes:</p>
373
374<ul>
375<li>Compute shaders
376<li>Separate shader objects
377<li>Indirect draw commands
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700378<li>Multisample and stencil textures
Robert Ly20555292014-06-13 23:28:19 -0700379<li>Shading language improvements
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700380<li>Extensions for advanced blend modes and debugging
Robert Ly20555292014-06-13 23:28:19 -0700381<li>Backward compatibility with OpenGL ES 2.0 and 3.0
382</ul>
383
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700384<p>The Java interface for OpenGL ES 3.1 on Android is provided with {@code GLES31}. When
Quddus Chongaa9d7782014-06-19 16:16:10 -0700385using OpenGL ES 3.1, be sure that you declare it in your manifest file with the
386<a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
387tag and the {@code android:glEsVversion} attribute. For example:</p>
Robert Ly20555292014-06-13 23:28:19 -0700388
389<pre>
390&lt;manifest&gt;
391 &lt;uses-feature android:glEsVersion="0x00030001" /&gt;
392 ...
393&lt;/manifest&gt;
394</pre>
395
Quddus Chongaa9d7782014-06-19 16:16:10 -0700396<p>For more information about using OpenGL ES, including how to check the
397device’s supported OpenGL ES version at runtime, see the
398<a href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL ES API guide</a>.</p>
Robert Ly20555292014-06-13 23:28:19 -0700399
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700400<h3 id="AndroidExtensionPack">Android Extension Pack</h3>
401
402<p>In addition to OpenGL ES 3.1, this release provides an extension pack with Java interfaces and
403native support for advanced graphics functionality. These extensions are treated as a single
404package by Android. (If the {@code ANDROID_extension_pack_es31} extension is present, your app can
405assume all extensions in the package are present and enable the shading language features with
406a single {@code #extension} statement.</p>
407<p>The extension pack supports:</p>
408<ul>
409<li>Guaranteed fragment shader support for shader storage buffers, images, and
410 atomics (fragment shader support is optional in OpenGL ES 3.1.)</li>
411<li>Tessellation and geometry shaders</li>
412<li>ASTC (LDR) texture compression format</li>
413<li>Per-sample interpolation and shading</li>
414<li>Different blend modes for each color attachment in a frame buffer</li>
415</ul>
416
417<p>The Java interface for the extension pack is provided with {@code GLES31Ext}.
418In your app manifest, you can declare that support for the extension pack is
419required, with the
420<a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
421tag, but the precise syntax is not finalized in the L Developer Preview.</p>
422
Robert Ly20555292014-06-13 23:28:19 -0700423<h2 id="Multimedia">Multimedia</h2>
424
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700425<h3 id="Camera-v2">Camera API for advanced camera capabilities</h3>
Robert Ly20555292014-06-13 23:28:19 -0700426
427<p>The L Developer Preview introduces the new {@code android.hardware.camera2}
Andrew Solovay68990cf2014-06-15 20:26:07 -0700428API to facilitate fine-grain photo capture and image processing. You can now
429programmatically access the camera devices available to the system with {@code
430CameraManager.getCameraIdList()} and connect to a specific device with {@code
431CameraManager.openCamera()}. To start capturing images, create a {@code
432CameraCaptureSession} and specify the {@link android.view.Surface} objects for
433the captured images. The {@code CameraCaptureSession} can be configured to take
434single shots or multiple images in a burst.</p>
Robert Ly20555292014-06-13 23:28:19 -0700435
436<p>To be notified when new images are captured, implement the
437{@code CameraCaptureSession.CaptureListener()} interface and set it in your
438capture request. Now when the system completes the image capture request, your
439{@code CameraCaptureSession.CaptureListener()} receives a call to
440{@code onCaptureCompleted()}, providing you with the image capture metadata in a
441{@code CaptureResult}.</p>
442
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700443<p>To see an example of how to use the updated Camera API, refer to the {@code Camera2Basic}
444and {@code Camera2Video} implementation samples in this release.</p>
445
Robert Ly20555292014-06-13 23:28:19 -0700446<h3 id="AudioPlayback">Audio playback</h3>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700447<p>This release includes the following changes to
448 {@link android.media.AudioTrack}:</p>
Robert Ly20555292014-06-13 23:28:19 -0700449<ul>
450 <li>Your app can now supply audio data in floating-point format
451({@code android.media.AudioFormat.ENCODING_PCM_FLOAT}). This permits greater
Quddus Chongaa9d7782014-06-19 16:16:10 -0700452dynamic range, more consistent precision, and greater headroom. Floating-point
453arithmetic is especially useful during intermediate calculations. Playback
Andrew Solovay68990cf2014-06-15 20:26:07 -0700454end-points use integer format for audio data, and with lower bit-depth. (In the
455L Developer Preview, portions of the internal pipeline are not yet
456floating-point.)
Quddus Chongaa9d7782014-06-19 16:16:10 -0700457 <li>Your app can now supply audio data as a {@link java.nio.ByteBuffer}, in
458the same format as provided by {@link android.media.MediaCodec}.
Robert Ly20555292014-06-13 23:28:19 -0700459 <li>The {@code WRITE_NON_BLOCKING} option can simplify buffering and
460 multithreading for some apps.
461</ul>
462
463<h3 id="MediaPlaybackControl">Media playback control</h3>
464<p>You can now build your own media controller app with the new
465{@code android.media.session.MediaController} class, which provides
466simplified transport controls APIs that replace those in
Andrew Solovay68990cf2014-06-15 20:26:07 -0700467{@link android.media.RemoteControlClient}. The {@code MediaController} class
468allows thread-safe control of playback from a non-UI process, making it easier
Robert Ly20555292014-06-13 23:28:19 -0700469to control your media playback service from your app’s user interface.
470
471<p>You can also create multiple controllers to send playback commands,
472media keys, and other events to the same ongoing
473{@code android.media.session.MediaSession}. When you add a controller, you must
474call {@code MediaSession.getSessionToken()} to request an access
475token in order for your app to interact with the session.</p>
476
Andrew Solovay68990cf2014-06-15 20:26:07 -0700477<p>You can now send transport commands such as "play", "stop", "skip", and
Robert Ly20555292014-06-13 23:28:19 -0700478"set rating" by using {@code MediaController.TransportControls}. To handle
Andrew Solovay68990cf2014-06-15 20:26:07 -0700479in-bound media transport commands from controllers attached to the session,
480override the callback methods in
Robert Ly20555292014-06-13 23:28:19 -0700481{@code MediaSession.TransportControlsCallback}.</p>
482
483<p>You can also create rich notifications that allow playback control tied to a
Andrew Solovay68990cf2014-06-15 20:26:07 -0700484media session with the new {@code android.app.Notification.MediaStyle} class. By
485using the new notification and media APIs, you will ensure that the System UI
486knows about your playback and can extract and show album art.</p>
Robert Ly20555292014-06-13 23:28:19 -0700487
488<h2 id="Storage">Storage</h2>
489
490<h3 id="DirectorySelection">Directory selection</h3>
491
Quddus Chongaa9d7782014-06-19 16:16:10 -0700492<p>The L Developer Preview extends the <a href="{@docRoot}guide/topics/providers/document-provider.html">Storage Access Framework</a> to let users select an entire directory subtree,
493giving apps read/write access to all contained documents without requiring user
494confirmation for each item.</p>
Robert Ly20555292014-06-13 23:28:19 -0700495
Quddus Chongaa9d7782014-06-19 16:16:10 -0700496<p>To select a directory subtree, build and send an
497{@code android.intent.action.OPEN_DOCUMENT_TREE} {@link android.content.Intent}.
498The system displays all
499{@link android.provider.DocumentsProvider} instances that support subtree selection,
500letting the user browse and select a directory. The returned URI represents access to the selected
501subtree. You can then use {@code DocumentsContract.buildChildDocumentsUriUsingTree()}
502and {@code DocumentsContract.buildDocumentUriUsingTree()} along with
503{@code ContentResolver.query()} to explore the subtree.</p>
Robert Ly20555292014-06-13 23:28:19 -0700504
Quddus Chongaa9d7782014-06-19 16:16:10 -0700505<p>The new {@code DocumentsContract.createDocument()} method lets you create
506new documents or directories anywhere under the subtree. To manage
507existing documents, use {@code DocumentsContract.renameDocument()} and
508{@code DocumentsContract.deleteDocument()}. Check {@code DocumentsContract.Document.COLUMN_FLAGS}
509to verify provider support for these calls before issuing them.</p>
Quddus Chong17305642014-06-18 12:19:06 -0700510
Quddus Chongaa9d7782014-06-19 16:16:10 -0700511<p>If you're implementing a {@link android.provider.DocumentsProvider} and want
512to support subtree selection, implement {@code DocumentsProvider.isChildDocument()}
513and include {@code Documents.Contract.FLAG_SUPPORTS_IS_CHILD} in your
514{@code Root.COLUMN_FLAGS}.</p>
515
516<p>The L Developer Preview also introduces new package-specific directories on
517shared storage where your app can place media files for inclusion in
518{@link android.provider.MediaStore}. The new
519{@code android.content.Context.getExternalMediaDirs()} returns paths to these
520directories on all shared storage devices. Similarly to
521{@link android.content.Context#getExternalFilesDir(java.lang.String) Context.getExternalFilesDir()},
522no additional permissions are needed by your app to access the returned paths. The
523platform periodically scans for new media in these directories, but you can also
524use {@link android.media.MediaScannerConnection} to explicitly scan for new
525content.</p>
Robert Ly20555292014-06-13 23:28:19 -0700526
527<h2 id="Wireless">Wireless &amp; Connectivity</h2>
528
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700529<h3 id="Multinetwork">Multiple network connections</h3>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700530<p>The L Developer Preview provides new multi-networking APIs. These let your app
Robert Ly20555292014-06-13 23:28:19 -0700531dynamically scan for available networks with specific capabilities, and
532establish a connection to them. This is useful when your app requires a
533specialized network, such as an SUPL, MMS, or carrier-billing network, or if
534you want to send data using a particular type of transport protocol.</p>
535
Andrew Solovay68990cf2014-06-15 20:26:07 -0700536<p>To select and connect to a network dynamically from your app follow these
537steps:</p>
538
539<ol>
540 <li>Create a {@link android.net.ConnectivityManager}.</li>
541 <li>Create a
542 {@code android.net.NetworkRequest} to specify the network features and transport
543 type your app is interested in.</li>
544 <li>To scan for suitable networks, call
545 {@code ConnectivityManager.requestNetwork()} or
546 {@code ConnectivityManager.registerNetworkCallback()}, and pass in the
547 {@code NetworkRequest} object and an implementation of
548 {@code ConnectivityManager.NetworkCallbackListener}.</li>
549
550</ol>
Robert Ly20555292014-06-13 23:28:19 -0700551
552<p>When the system detects a suitable network, it connects to the network and
553invokes the {@code NetworkCallbackListener.onAvailable()} callback. You can use
554the {@code android.net.Network} object from the callback to get additional
Andrew Solovay68990cf2014-06-15 20:26:07 -0700555information about the network, or to direct traffic to use the selected
556network.</p>
Robert Ly20555292014-06-13 23:28:19 -0700557
558<h3 id="BluetoothBroadcasting">Bluetooth broadcasting</h3>
Quddus Chongaa9d7782014-06-19 16:16:10 -0700559<p>Android 4.3 introduced platform support for
560 <a href="{@docRoot}guide/topics/connectivity/bluetooth-le.html">Bluetooth Low Energy</a>
Robert Ly20555292014-06-13 23:28:19 -0700561(BLE) in the central role. In the L Developer Preview, an Android device can now
Andrew Solovay68990cf2014-06-15 20:26:07 -0700562act as a Bluetooth LE <em>peripheral device</em>. Apps can use this capability
563to make their presence known to
Robert Ly20555292014-06-13 23:28:19 -0700564nearby devices. For instance, you can build apps that allow a device to
565function as a pedometer or health monitor and communicate its data with another
566BLE device.</p>
567
Quddus Chongaa9d7782014-06-19 16:16:10 -0700568<p>The new {@code android.bluetooth.le} APIs enable your apps to broadcast
569advertisements, scan for responses, and form connections with nearby BLE devices.
Robert Ly20555292014-06-13 23:28:19 -0700570You must add the {@code android.permission.BLUETOOTH_ADMIN} permission in your
571manifest in order for your app to use the new advertising and scanning features.</a>
572
Andrew Solovay68990cf2014-06-15 20:26:07 -0700573<p>To begin Bluetooth LE advertising so that other devices can discover
Quddus Chong6a5dd932014-07-11 11:55:23 -0700574your app, call {@code android.bluetooth.le.BluetoothAdvertiser.startAdvertising()}
Andrew Solovay68990cf2014-06-15 20:26:07 -0700575and pass in an implementation of the
576{@code android.bluetooth.le.AdvertiseCallback} class. The callback object
577receives a report of the success or failure of the advertising operation.</p>
Robert Ly20555292014-06-13 23:28:19 -0700578
Andrew Solovay68990cf2014-06-15 20:26:07 -0700579<p> The L Developer Preview introduces the {@code
580android.bluetooth.le.ScanFilter} class so that your app can scan for only the
581specific types of devices it is interested in. To begin scanning for Bluetooth
582LE devices, call {@code android.bluetooth.le.BluetoothLeScanner.startScan()} and
583pass in a list of filters. In the method call, you must also provide an
Robert Ly20555292014-06-13 23:28:19 -0700584implementation of {@code android.bluetooth.le.ScanCallback} to report if a
Andrew Solovay68990cf2014-06-15 20:26:07 -0700585Bluetooth LE advertisement is found. </p>
Robert Ly20555292014-06-13 23:28:19 -0700586
587<h3 id="NFCEnhancements">NFC enhancements</h3>
588<p>The L Developer Preview adds these enhancements to enable wider and more
589flexible use of NFC:</p>
590
591<ul>
592<li>Android Beam is now available in the share menu.
593<li>Your app can invoke the Android Beam on the user’s device to share data by
594calling {@code android.nfc.NfcAdapter.invokeBeam()}. This avoids the need for
595the user to manually tap the device against another NFC-capable device to
596complete the data transfer.
Andrew Solovay68990cf2014-06-15 20:26:07 -0700597<li>You can use the new {@code android.nfc.NdefRecord.createTextRecord()} method
598to create an NDEF record containing UTF-8 text data.
Robert Ly20555292014-06-13 23:28:19 -0700599<li>If you are developing a payment app, you now have the ability to
600register an NFC application ID (AID) dynamically by calling
601{@code android.nfc.cardemulation.CardEmulation.registerAidsForService()}.
602You can also use {@code android.nfc.cardemulation.CardEmulation.setPreferredService()}
603to set the preferred card emulation service that should be used when a specific
604activity is in the foreground.
605</ul>
606
607<h2 id="Power">Power Efficiency</h2>
608
609<h3 id="JobScheduler">Scheduling jobs</h3>
610<p>The L Developer Preview provides a new {@code android.app.job.JobScheduler}
Quddus Chongd50a6f82014-06-15 12:13:18 -0700611API that lets you optimize battery life by defining jobs for the system to run
Andrew Solovay68990cf2014-06-15 20:26:07 -0700612asynchronously at a later time or under specified conditions (such as when the
613device is charging). This is useful in such situations as:</p>
614<ul>
Quddus Chong17305642014-06-18 12:19:06 -0700615 <li>The app has non-user-facing work that you can defer.</li>
616 <li>The app has work you'd prefer to do when the unit is plugged in.</li>
617 <li>The app has a task that requires network access (or requires a Wi-Fi
Andrew Solovay68990cf2014-06-15 20:26:07 -0700618 connection).</li>
619 <li>The app has a number of tasks that you want to run as a batch on a regular
620 schedule.</li>
Robert Ly20555292014-06-13 23:28:19 -0700621
Andrew Solovay68990cf2014-06-15 20:26:07 -0700622</ul>
623
624<p>A unit of work is encapsulated by a {@code android.app.job.JobInfo} object.
625This object provides an exact description of the criteria to be used for
626scheduling.</p>
Robert Ly20555292014-06-13 23:28:19 -0700627
628<p>Use the {@code android.app.job.JobInfo.Builder} to configure how the
629scheduled task should run. You can schedule the task to run under specific
Andrew Solovay68990cf2014-06-15 20:26:07 -0700630conditions, such as:</p>
631
632<ul>
633 <li>The device is charging</li>
634 <li>The device is connected to an unmetered network</li>
635 <li>The system deems the device to be idle</li>
Quddus Chong17305642014-06-18 12:19:06 -0700636 <li>Completion with a minimum delay or within a specific deadline.</li>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700637</ul>
Robert Ly20555292014-06-13 23:28:19 -0700638
639<p>For example, you can add code like this to run your task on an
640unmetered network:</p>
641
642<pre>
643JobInfo uploadTask = new JobInfo.Builder(mJobId, mServiceComponent)
644 .setRequiredNetworkCapabilities(JobInfo.NetworkType.UNMETERED)
645 .build();
646
647JobScheduler jobScheduler =
648 (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE)
649jobScheduler.schedule(uploadTask);
650</pre>
651
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700652<p>To see an example of how to use the {@code JobScheduler} API, refer to the
653{@code JobSchedulerSample} implementation sample in this release.</p>
654
Quddus Chong17305642014-06-18 12:19:06 -0700655<h3 id="PowerMeasurementTools">Developer tools for power measurement</h3>
Robert Ly20555292014-06-13 23:28:19 -0700656<p>The L Developer Preview provides several new developer tools and APIs to help
657you better measure and understand your app's power usage.</p>
658
659<dl>
660<dt><strong>batterystats</strong></dt>
661<dd>
662<p>The {@code dumpsys batterystats} command allows you to generate interesting
663statistical data about battery usage on a device, organized by unique user ID
664(UID). The statistics generated by the tool include:</p>
665
666<ul>
667<li>History of battery related events
668<li>Global statistics for the device
669<li>Approximated power use per UID and system component
670<li>Per-app mobile ms per packet
671<li>System UID aggregated statistics
672<li>App UID aggregated statistics
673</ul>
674
Quddus Chongd50a6f82014-06-15 12:13:18 -0700675<p>Use the {@code --help} option to learn about the various options for
Andrew Solovay68990cf2014-06-15 20:26:07 -0700676tailoring the output. For example, to print battery usage
677statistics for a given app package since the device was last charged, run this
Quddus Chongd50a6f82014-06-15 12:13:18 -0700678command:
Robert Ly20555292014-06-13 23:28:19 -0700679<pre>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700680$ adb shell dumpsys batterystats --charged &lt;package-name&gt;
Robert Ly20555292014-06-13 23:28:19 -0700681</pre>
682</dd>
683
684<dt><strong>Battery Historian</strong></dt>
685<dd>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700686<p>The Battery Historian tool ({@code historian.par}) analyzes Android
687bug reports from the L Developer Preview and creates an HTML visualization of
688power-related events. It can
689also visualize power consumption data from a power monitor, and attempts to
690map power usage to the wake locks seen. You can find the Battery Historian tool
Robert Ly20555292014-06-13 23:28:19 -0700691in {@code &lt;sdk&gt;/tools}.</p>
692
Andrew Solovay68990cf2014-06-15 20:26:07 -0700693<img src="images/battery_historian.png"
694 srcset="images/battery_historian@2x.png 2x"
Quddus Chongaa9d7782014-06-19 16:16:10 -0700695 alt="" width="760" height="462"
Quddus Chong17305642014-06-18 12:19:06 -0700696 id="figure2" />
Andrew Solovay68990cf2014-06-15 20:26:07 -0700697<p class="img-caption">
Quddus Chong17305642014-06-18 12:19:06 -0700698 <strong>Figure 2.</strong>HTML visualization generated by the Battery
Andrew Solovay68990cf2014-06-15 20:26:07 -0700699 Historian tool.
700</p>
701
702<p>For best results, you should first enable full wake lock reporting, to allow
Robert Ly20555292014-06-13 23:28:19 -0700703the Battery Historian tool to monitor uninterrupted over an extended period of
704time:</p>
705<pre>
706$ adb shell dumpsys batterystats --enable full-wake-history
707</pre>
708
709<p>You should also reset battery statistics at the beginning of a
710measurement:</p>
711<pre>
712$ adb shell dumpsys batterystats --reset
713</pre>
714
715<p>To generate an HTML visualization:</p>
716<pre>
717$ historian.par [-p powerfile] bugreport.txt > out.html
718</pre>
719</dd>
720
Robert Ly20555292014-06-13 23:28:19 -0700721</dl>
722
723<h2 id="Enterprise">Enterprise</h2>
724<h3 id="ManagedProvisioning">Managed provisioning</h3>
725
Andrew Solovay68990cf2014-06-15 20:26:07 -0700726<div class="figure" style="width:360px">
727 <img src="images/managed_apps_launcher.png"
728 srcset="images/managed_apps_launcher@2x.png 2x"
Quddus Chongaa9d7782014-06-19 16:16:10 -0700729 alt="" width="360" height="609" id="figure3" />
Andrew Solovay68990cf2014-06-15 20:26:07 -0700730 <p class="img-caption">
Quddus Chong17305642014-06-18 12:19:06 -0700731 <strong>Figure 3.</strong> Launcher screen showing managed apps (marked with
Andrew Solovay68990cf2014-06-15 20:26:07 -0700732 a lock badge)
733 </p>
734</div>
735
Robert Ly20555292014-06-13 23:28:19 -0700736<p>The L Developer Preview provides new functionality for running apps within
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700737an enterprise environment. A
738<a href="{@docRoot}guide/topics/admin/device-admin.html">device administrator</a> can
Quddus Chong26aec762014-06-24 10:14:12 -0700739initiate a managed provisioning process to add a co-present but separate <em>managed profile</em> to a device, if the user has an existing personal account.
740Apps that are associated with managed profiles will appear alongside
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700741non-managed apps in the user’s Launcher, Recent apps screen, and notifications.</p>
Robert Ly20555292014-06-13 23:28:19 -0700742
Andrew Solovay68990cf2014-06-15 20:26:07 -0700743<p>To start the managed provisioning process, send {@code
744ACTION_PROVISION_MANAGED_PROFILE} in an {@link android.content.Intent}. If the
745call is successful, the system triggers the {@code
746android.app.admin.DeviceAdminReceiver. onProfileProvisioningComplete()} callback.
747You can then call {@code app.admin.DevicePolicyManager. setProfileEnabled()} to
Quddus Chong26aec762014-06-24 10:14:12 -0700748enable this managed profile.</p>
Robert Ly20555292014-06-13 23:28:19 -0700749
Andrew Solovay68990cf2014-06-15 20:26:07 -0700750<p>If you are developing a Launcher app, you can use the new {@code
751android.content.pm.LauncherApps} class to get a list of launchable activities
Quddus Chong26aec762014-06-24 10:14:12 -0700752for the current user and any associated managed profiles. Your Launcher can make
Andrew Solovay68990cf2014-06-15 20:26:07 -0700753the managed apps visually prominent by appending a “work” badge to the icon
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700754drawable with {@code android.os.UserManager. getBadgeDrawableForUser()}.</p>
755
756<p>To see an example of how to use the new functionality, refer to the
757{@code BasicManagedProfile} implementation sample in this release.</p>
Robert Ly20555292014-06-13 23:28:19 -0700758
Quddus Chongaa9d7782014-06-19 16:16:10 -0700759<h3 id="TaskLocking">Task locking</h3>
760<p>The L Developer Preview introduces a new task locking API that
Quddus Chong17305642014-06-18 12:19:06 -0700761lets you temporarily restrict users from leaving your app or being interrupted
Quddus Chongaa9d7782014-06-19 16:16:10 -0700762by notifications. This could be used, for example, if you are developing an
763education app to support high stakes assessment requirements on Android.
764Once your app activates this mode, users will not be able to see
765notifications, access other apps, or return to the Home screen, until your
Quddus Chong17305642014-06-18 12:19:06 -0700766app exits the mode.</p>
767
Quddus Chongaa9d7782014-06-19 16:16:10 -0700768<p>To prevent unauthorized usage, only authorized apps can activate task locking.
769Furthermore, task locking authorization must be granted by a
770specially-configured <em>device owner</em> app, through the {@code android.app.admin.DevicePolicyManager.setLockTaskComponents()} method.</p>
Quddus Chong17305642014-06-18 12:19:06 -0700771
Quddus Chongaa9d7782014-06-19 16:16:10 -0700772<p>To set up a device owner, follow these steps:</p>
773<ol>
Quddus Chong26aec762014-06-24 10:14:12 -0700774<li>Attach a device running an Android <a href="https://source.android.com/source/building-running.html" class="external-link">{@code userdebug}</a> build to your development machine.</li>
Quddus Chongaa9d7782014-06-19 16:16:10 -0700775<li>Install your device owner app.</li>
776<li>Create a {@code device_owner.xml} file and save it to the {@code /data/system}
777directory on the device.
778<pre>
779$ adb root
780$ adb shell stop
781$ rm /tmp/device_owner.xml
782$ echo "&lt;?xml version='1.0' encoding='utf-8' standalone='yes' ?&gt;"
783&gt;&gt; /tmp/device_owner.xml
Quddus Chong9a3dd192014-07-08 10:07:43 -0700784$ echo "&lt;device-owner package=\"&lt;your_device_owner_package&gt;\"
Quddus Chongaa9d7782014-06-19 16:16:10 -0700785name=\"*&lt;your_organization_name&gt;\" /&gt;" &gt;&gt; /tmp/device_owner.xml
786$ adb push /tmp/device_owner.xml /data/system/device_owner.xml
787$ adb reboot
788</pre>
789</li>
790</ol>
Quddus Chong17305642014-06-18 12:19:06 -0700791
Quddus Chongaa9d7782014-06-19 16:16:10 -0700792<p>Before using the task locking API in your app, verify that your activity is
793authorized by calling {@code DevicePolicyManager.isLockTaskPermitted()}.</p>
794
795<p>To activate task locking, call
Quddus Chong17305642014-06-18 12:19:06 -0700796{@code android.app.Activity.startLockTask()} from your authorized activity.</p>
797
Quddus Chongaa9d7782014-06-19 16:16:10 -0700798<p>When task locking is active, the following behavior takes effect:</p>
Quddus Chong17305642014-06-18 12:19:06 -0700799
800<ul>
Quddus Chongaa9d7782014-06-19 16:16:10 -0700801<li>The status bar is blank, and user notifications and status information is
802hidden.</li>
803<li>The Home and Recent Apps buttons are hidden.</li>
Quddus Chong17305642014-06-18 12:19:06 -0700804<li>Other apps may not launch new activities.</li>
805<li>The current app may start new activities, as long as doing so does not
806create new tasks.</li>
Quddus Chongaa9d7782014-06-19 16:16:10 -0700807<li>The user remains locked on your app until an authorized activity calls
808{@code Activity.stopLockTask()}.</li>
Quddus Chong17305642014-06-18 12:19:06 -0700809</ul>
810
Robert Ly20555292014-06-13 23:28:19 -0700811<h2 id="Printing">Printing Framework</h2>
812
813<h3 id="PDFRender">Render PDF as bitmap</h3>
814<p>You can now render PDF document pages into bitmap images for printing by
815using the new {@code android.graphics.pdf.PdfRenderer} class. You must specify a
Quddus Chongaa9d7782014-06-19 16:16:10 -0700816{@link android.os.ParcelFileDescriptor} that is seekable (that is, the content
817can be randomly accessed) on which the system writes the the printable content.
818Your app can obtain a page for rendering with {@code openPage()}, then call
819{@code render()} to turn the opened {@code PdfRenderer.Page} into a bitmap. You
820can also set additional parameters if you only want to convert a portion of the
821document into a bitmap image (for example, to implement
Quddus Chong26aec762014-06-24 10:14:12 -0700822<a href="http://en.wikipedia.org/wiki/Tiled_rendering" class="external-link">tiled rendering</a> in
Quddus Chongaa9d7782014-06-19 16:16:10 -0700823order to zoom in on the document).</p>
Robert Ly20555292014-06-13 23:28:19 -0700824
825<h2 id="TestingA11y">Testing &amp; Accessibility </h2>
826
Andrew Solovay68990cf2014-06-15 20:26:07 -0700827<h3 id="TestingA11yImprovements">Testing and accessibility improvements</h3>
Robert Ly20555292014-06-13 23:28:19 -0700828<p>The L Developer Preview adds the following support for testing and
829accessibility:</p>
830
831<ul>
832<li>You can use the new {@code android.app.UiAutomation.getWindowAnimationFrameStats()}
833and {@code android.app.UiAutomation.getWindowContentFrameStats()} methods to
834capture frame statistics for window animations and content. This lets you
835write instrumentation tests to evaluate if the app under test is rendering
836frames at a sufficient refresh frequency to provide a smooth user experience.
Andrew Solovay68990cf2014-06-15 20:26:07 -0700837
Robert Ly20555292014-06-13 23:28:19 -0700838<li>You can execute shell commands from your instrumentation test with the new
839{@code android.app.UiAutomation.executeShellCommand()}. The command execution
Andrew Solovay68990cf2014-06-15 20:26:07 -0700840is similar to running {@code adb shell} from a host connected to the device. This
Robert Ly20555292014-06-13 23:28:19 -0700841allows you to use shell based tools such as {@code dumpsys}, {@code am},
842{@code content}, and {@code pm}.
Andrew Solovay68990cf2014-06-15 20:26:07 -0700843
Robert Ly20555292014-06-13 23:28:19 -0700844<li>Accessibility services and test tools that use the accessibility APIs
Andrew Solovay68990cf2014-06-15 20:26:07 -0700845(such as <a href="{@docRoot}tools/help/uiautomator/index.html">uiautomator</a>)
Robert Ly20555292014-06-13 23:28:19 -0700846can now retrieve detailed information about the properties of windows on the
847screen that sighted users can interact with. To retrieve a list of
Andrew Solovay68990cf2014-06-15 20:26:07 -0700848{@code android.view.accessibility.AccessibilityWindowInfo} objects
Quddus Chongaa9d7782014-06-19 16:16:10 -0700849representing the windows information, call the new
Robert Ly20555292014-06-13 23:28:19 -0700850{@code android.accessibilityservice.AccessibilityService.getWindows()} method.
851<li>You can use the new {@code android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction} to define standard or customized
Andrew Solovay68990cf2014-06-15 20:26:07 -0700852actions to perform on an {@link android.view.accessibility.AccessibilityNodeInfo}.
Robert Ly20555292014-06-13 23:28:19 -0700853The new {@code AccessibilityAction} class replaces the actions-related APIs
854previously found in {@code AccessibilityNodeInfo}.
855</ul>
856
Quddus Chong26aec762014-06-24 10:14:12 -0700857<h2 id="IME">IME</h2>
858
859<h3 id="Switching">Easier switching between input languages</h3>
860
861<p>Beginning in the L Developer Preview, users can more easily switch between
862all <a href="{@docRoot}guide/topics/text/creating-input-method.html">input
863method editors (IME)</a> supported by the platform. Performing the designated
864switching action (usually touching a Globe icon on the soft keyboard) will cycle
865among all such IMEs. This change takes place in
866{@link android.view.inputmethod.InputMethodManager#shouldOfferSwitchingToNextInputMethod
867InputMethodManager.shouldOfferSwitchingToNextInputMethod()}.</p>
868
869<p>In addition, the framework now checks whether the next IME includes a
870switching mechanism at all (and, thus, whether that IME supports switching to
871the IME after it). An
872IME with a switching mechanism will not cycle to an IME without one. This
873change takes place in
874{@link android.view.inputmethod.InputMethodManager#switchToNextInputMethod
875InputMethodManager.switchToNextInputMethod}.
876
877<p>To see an example of how to use the updated IME-switching APIs, refer to the
878updated soft-keyboard implementation sample in this release.</p>
879
Andrew Solovay68990cf2014-06-15 20:26:07 -0700880<h2 id="Manifest">Manifest Declarations</h2>
Robert Ly20555292014-06-13 23:28:19 -0700881
882<h3 id="ManifestFeatures">Declarable required features</h3>
Quddus Chongaa9d7782014-06-19 16:16:10 -0700883<p>The following values are now supported in the
884<a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
885element, so you can ensure that your app is installed only on devices that provide the features
Robert Ly20555292014-06-13 23:28:19 -0700886your app needs.</p>
887
888<ul>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700889<li>{@code FEATURE_LEANBACK}. Declares that your app must be installed only on
Quddus Chongaa9d7782014-06-19 16:16:10 -0700890devices that support the
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700891<a href="{@docRoot}training/tv/index.html">Android TV</a> user interface.
Quddus Chongaa9d7782014-06-19 16:16:10 -0700892Example:
Robert Ly20555292014-06-13 23:28:19 -0700893<pre>
894&lt;uses-feature android:name="android.software.leanback"
895 android:required="true" /&gt;
896</pre>
897
Andrew Solovay68990cf2014-06-15 20:26:07 -0700898<li>{@code FEATURE_WEBVIEW}. Declares that your app must only be installed on
899devices that fully implement the {@code android.webkit.*} APIs. Example:
Robert Ly20555292014-06-13 23:28:19 -0700900<pre>
901&lt;uses-feature android:name="android.software.webview"
902 android:required="true" /&gt;
903</pre>
904</ul>
905
Quddus Chonga2cc6cc2014-06-23 12:34:59 -0700906<p class="note">For a detailed view of all API changes in the L Developer Preview, see the
907<a href="{@docRoot}preview/reference.html">API Differences Report</a>.</p>