blob: 2fa029fb90292c486e611646ad8cf460a56c638a [file] [log] [blame]
Robert Ly20555292014-06-13 23:28:19 -07001page.title=L Developer Preview APIs
2excludeFromSuggestions=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>
Robert Ly20555292014-06-13 23:28:19 -070021 <li><a href="#BehaviorFullscreen">If your app uses fullScreenIntent...</a></li>
22 <li><a href="#BehaviorGetRecentTasks">If your app uses ActivityManager.getRecentTasks()...</a></li>
23 </ol>
24 </li>
25 <li><a href="#UI">User Interface</a>
26 <ol>
27 <li><a href="#MaterialDesign">Material design support</a></li>
Andrew Solovay68990cf2014-06-15 20:26:07 -070028 <li><a href="#DoNotDisturb">Do Not Disturb mode</a></li>
Robert Ly20555292014-06-13 23:28:19 -070029 <li><a href="#LockscreenNotifications">Lockscreen notifications</a></li>
30 <li><a href="#NotificationsMetadata">Notifications metadata</a></li>
Andrew Solovay68990cf2014-06-15 20:26:07 -070031 <li><a href="#Recents">Concurrent documents and activities in the Recents screen</a></li>
Robert Ly20555292014-06-13 23:28:19 -070032 <li><a href="#WebView">WebView updates</a></li>
33 </ol>
34 </li>
35 <li><a href="#UserInput">User Input</a>
36 <ol>
37 <li><a href="#IME">IME bug fixes and improvements</a></li>
38 </ol>
39 </li>
40 <li><a href="#Animations">Animation &amp; Graphics</a>
41 <ol>
42 <li><a href="#OpenGLES-3-1">Support for OpenGL ES 3.1</a></li>
43 </ol>
44 </li>
45 <li><a href="#Multimedia">Multimedia</a>
46 <ol>
Andrew Solovay68990cf2014-06-15 20:26:07 -070047 <li><a href="#Camera-v2">Camera v2 API</a></li>
Robert Ly20555292014-06-13 23:28:19 -070048 <li><a href="#AudioPlayback">Audio playback</a></li>
49 <li><a href="#MediaPlaybackControl">Media playback control</a></li>
50 </ol>
51 </li>
52 <li><a href="#Storage">Storage</a>
53 <ol>
54 <li><a href="#DirectorySelection">Directory selection</a></li>
55 </ol>
56 </li>
57 <li><a href="#Wireless">Wireless and Connectivity</a>
58 <ol>
59 <li><a href="#Multinetwork">Dynamic network selection and seamless handoff</a></li>
60 <li><a href="#BluetoothBroadcasting">Bluetooth broadcasting</a></li>
Andrew Solovay68990cf2014-06-15 20:26:07 -070061 <li><a href="#NFCEnhancements">NFC enhancements</a></li>
Robert Ly20555292014-06-13 23:28:19 -070062 </ol>
63 </li>
64 <li><a href="#Power">Power Efficiency</a>
65 <ol>
66 <li><a href="#JobScheduler">Scheduling Jobs</a></li>
67 <li><a href="#PowerMeasurementTools">Developer tools and APIs for power measurement</a>
68 </ol>
69 </li>
70 <li><a href="#Enterprise">Enterprise</a>
71 <ol>
72 <li><a href="#ManagedProvisioning">Managed provisioning</a></li>
73 </ol>
74 </li>
75 <li><a href="#Printing">Printing Framework</a>
76 <ol>
Andrew Solovay68990cf2014-06-15 20:26:07 -070077 <li><a href="#PDFRender">Render PDF as bitmap</a></li>
Robert Ly20555292014-06-13 23:28:19 -070078 </ol>
79 </li>
80 <li><a href="#TestingA11y">Testing &amp; Accessibility</a>
81 <ol>
82 <li><a href="#TestingA11yImprovements">Testing and accessibility improvements</a></li>
83 </ol>
84 </li>
85 <li><a href="#Manifest">Manifest Declarations</a>
86 <ol>
87 <li><a href="#ManifestFeatures">Declarable required features</a></li>
88 <li><a href="#ManifestPermissions">User permissions</a></li>
89 </ol>
90 </li>
91</ol>
92
93<h2>See also</h2>
94<ol>
95<li><a href="{@docRoot}sdk/api_diff/20/changes.html">API
96Differences Report &raquo;</a> </li>
97</ol>
98
99</div>
100</div>
101
Andrew Solovay68990cf2014-06-15 20:26:07 -0700102<p>The L Developer Preview gives you an advance look at the upcoming release for
103the Android platform,
104which offers new features for users and app developers. This document provides
105an introduction to the most notable APIs.</p>
Robert Ly20555292014-06-13 23:28:19 -0700106
Andrew Solovay68990cf2014-06-15 20:26:07 -0700107<p>The L Developer Preview is intended for <strong>developer early adopters</strong> and
108<strong>testers</strong>. If you are interested in influencing the direction of the
109Android framework, <a href="{@docRoot}preview/setup-sdk.html">give the L
110Developer Preview a try</a> and send us your feedback!</p>
Robert Ly20555292014-06-13 23:28:19 -0700111
Andrew Solovay68990cf2014-06-15 20:26:07 -0700112<p class="caution"><strong>Caution:</strong> Do not not publish apps
113that use the L Developer Preview to the Google Play store.</p>
114
115<p class="note"><strong>Note:</strong> This document often refers to classes and
116methods that do not yet have reference material available on <a
117href="{@docRoot}">developer.android.com</a>. These API elements are
118formatted in {@code code style} in this document (without hyperlinks). For the
119preliminary API documentation for these elements, download the <a
120href="{@docRoot}preview/l-developer-preview-reference.zip">preview
121reference</a>.</p>
Robert Ly20555292014-06-13 23:28:19 -0700122
123<h2 id="Behaviors">Important Behavior Changes</h2>
124
125<p>If you have previously published an app for Android, be aware that your app
Andrew Solovay68990cf2014-06-15 20:26:07 -0700126 might be affected by changes in the upcoming release.</p>
127
128<h3 id="ART">New Android Runtime (ART)</h3>
129
130<p>The 4.4 release introduced a new, experimental Android runtime, ART. Under
1314.4, ART was optional, and the default runtime remained Dalvik. With the L Developer Preview, ART is
132now the default runtime.</p>
133
134<p>For an overview of ART's new features, see
135<a href="https://source.android.com/devices/tech/dalvik/art.html">Introducing
136ART</a>. Some of the major new features are:</p>
137
138<ul>
139 <li>Ahead-of-Time (AOT) compilation</li>
140 <li>Improved garbage collection (GC)</li>
141 <li>Improved debugging support</li>
142</ul>
143
144<p>Most Android apps should just work without change under ART. However, some
145techniques that work on Dalvik do not work on ART. For information about the
146most important issues, see
147<a href="{@docRoot}guide/practices/verifying-apps-art.html">Verifying App
148Behavior on the Android Runtime (ART)</a>. Pay particular attention if:</p>
149
150<ul>
151 <li>Your app uses Java Native Interface (JNI) to run C/C++ code.</li>
152 <li>You use development tools that generate non-standard code (such as some
153 obfuscators).</li>
154 <li>You use techniques that are incompatible with compacting garbage
155 collection. (ART does not currently implement compacting GC, but
156 compacting GC is under development in the Android Open-Source
157 Project.)</li>
158</ul>
Robert Ly20555292014-06-13 23:28:19 -0700159
160<h3 id="BehaviorNotifications">If your app implements notifications...</h3>
161
Andrew Solovay68990cf2014-06-15 20:26:07 -0700162<p>Notifications are drawn with dark text atop white (or very light)
Robert Ly20555292014-06-13 23:28:19 -0700163backgrounds to match the new material design widgets. Make sure that all your
Andrew Solovay68990cf2014-06-15 20:26:07 -0700164notifications look right with the new color scheme:</p>
Robert Ly20555292014-06-13 23:28:19 -0700165
Andrew Solovay68990cf2014-06-15 20:26:07 -0700166<ul>
167
168 <li>Update or remove assets that involve color.</li>
169
170 <li>The system automatically inverts action icons in notifications. Use
171 {@code android.app.Notification.Builder.setColor()} to set an accent color
172 in a circle behind your {@link android.app.Notification#icon} image.</li>
173
174 <li>The system ignores all non-alpha channels in action icons and the main
175 notification icon. You should assume that these icons are alpha-only.</li>
176
177</ul>
Robert Ly20555292014-06-13 23:28:19 -0700178
179<p>If you are currently adding sounds and vibrations to your notifications by
180using the {@link android.media.Ringtone}, {@link android.media.MediaPlayer},
Andrew Solovay68990cf2014-06-15 20:26:07 -0700181or {@link android.os.Vibrator} classes, remove this code so that
182the system can present notifications correctly in <a href="#DoNotDisturb">Do Not Disturb</a> mode.
183Instead, use the {@link android.app.Notification.Builder} methods instead to add
184sounds and vibration.</p>
Robert Ly20555292014-06-13 23:28:19 -0700185
186<h3 id="BehaviorMediaControl">If your app uses RemoteControlClient...</h3>
187
Andrew Solovay68990cf2014-06-15 20:26:07 -0700188<p>Lockscreens in the L Developer Preview do not show transport controls for your
Robert Ly20555292014-06-13 23:28:19 -0700189{@link android.media.RemoteControlClient}. Instead, your app can provide
190media playback control from the lockscreen through a media notification. This
191gives your app more control over the presentation of media buttons, while
192providing a consistent experience for users across the lockscreen and
Quddus Chongd50a6f82014-06-15 12:13:18 -0700193unlocked device.</p>
Robert Ly20555292014-06-13 23:28:19 -0700194
Andrew Solovay68990cf2014-06-15 20:26:07 -0700195<p>Call {@code
196Notification.Builder.setVisibility(Notification.VISIBILITY_PUBLIC)} to mark a
197notification as safe to display on the lockscreen (even when the lockscreen is
198secured with a PIN, pattern, or password). For more information, see
199<a href="#LockscreenNotifications">Lockscreen Notifications</a>.</p>
Robert Ly20555292014-06-13 23:28:19 -0700200
201<h3 id="BehaviorFullscreen">If your app uses fullScreenIntent...</h3>
202
203<p>Notifications now appear in a small floating window if all these conditions
Andrew Solovay68990cf2014-06-15 20:26:07 -0700204are met:</p>
205
206<ul>
207 <li>The user’s activity is in fullscreen mode,</li>
208 <li>The screen is on, and</li>
209 <li>The device is unlocked</li>
210</ul>
211
212<p>If your app implements fullscreen activities, make sure that
Robert Ly20555292014-06-13 23:28:19 -0700213these heads-up notifications are presented correctly.</p>
214
215<h3 id="BehaviorGetRecentTasks">If your app uses ActivityManager.getRecentTasks()...</h3>
216
Andrew Solovay68990cf2014-06-15 20:26:07 -0700217<p>With the introduction of the new <em>concurrent documents and activities tasks</em> feature in the upcoming
218release (see <a href="#Recents">Concurrent documents and activities in Recents
219screen</a> below),
220the {@link android.app.ActivityManager#getRecentTasks
221ActivityManager.getRecentTasks()} method is now
222deprecated to improve user privacy. For backward
223compatibility, this method still returns a small subset of its data, including the
Robert Ly20555292014-06-13 23:28:19 -0700224calling application’s own tasks and possibly some other non-sensitive tasks
Andrew Solovay68990cf2014-06-15 20:26:07 -0700225(such as Home). If your app is using this method to retrieve its own tasks,
Robert Ly20555292014-06-13 23:28:19 -0700226use {@code android.app.ActivityManager.getAppTasks()} instead to retrieve that
227information.</p>
228
229<h2 id="UI">User Interface</h2>
230
231<h3 id="MaterialDesign">Material design support</h3>
232
Andrew Solovay68990cf2014-06-15 20:26:07 -0700233
234<p>The upcoming release adds support for Android's new <em>material</em> design
235style. You can create
236apps with material design that are visually dynamic and have UI element transitions
237that feel natural to users. This support includes:</p>
238
Robert Ly20555292014-06-13 23:28:19 -0700239<ul>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700240
241 <li>The material theme</li>
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700242 <li>View shadows</li>
243 <li>The {@code RecyclerView} widget</li>
244 <li>Drawable animation and styling effects</li>
245 <li>Material design animation and activity transition effects</li>
246 <li>Animators for view properties based on the state of a view</li>
247 <li>Customizable UI widgets and app bars with color palettes that you control</li>
Robert Ly20555292014-06-13 23:28:19 -0700248</ul>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700249
Robert Ly20555292014-06-13 23:28:19 -0700250<p>To learn more about adding material design functionality to your app, see
Andrew Solovay68990cf2014-06-15 20:26:07 -0700251<a href="{@docRoot}preview/material/index.html">Material Design</a>.</p>
Robert Ly20555292014-06-13 23:28:19 -0700252
253<h3 id="LockscreenNotifications">Lockscreen notifications</h3>
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700254<p>Lockscreens in the L Developer Preview have the ability to present notifications.
255Users can choose via <em>Settings</em> whether to allow sensitive notification
Robert Ly20555292014-06-13 23:28:19 -0700256content to be shown over a secure lockscreen.</p>
257
258<p>Your app can control the level of detail visible when its notifications are
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700259displayed over the secure lockscreen. To control the visibility level, call
Robert Ly20555292014-06-13 23:28:19 -0700260{@code android.app.Notification.Builder.setVisibility()} and specify one of these
261values:</p>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700262
Robert Ly20555292014-06-13 23:28:19 -0700263<ul>
264<li>{@code VISIBILITY_PRIVATE}. Shows basic information, such as the
265notification’s icon, but hides the notification’s full content. If you want to
266provide a redacted public version of your notification for the system to display
Andrew Solovay68990cf2014-06-15 20:26:07 -0700267on a secure lockscreen, create a public notification object and put a reference
268to it in the private notification's {@code publicVersion} field.</li>
Robert Ly20555292014-06-13 23:28:19 -0700269<li>{@code VISIBILITY_PUBLIC}. Shows the notification’s full content. This is
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700270 the system default if visibility is left unspecified.</li>
Robert Ly20555292014-06-13 23:28:19 -0700271<li>{@code VISIBILITY_SECRET}. Shows only the most minimal information,
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700272excluding even the notification’s icon.</li>
Robert Ly20555292014-06-13 23:28:19 -0700273</ul>
274
Andrew Solovay68990cf2014-06-15 20:26:07 -0700275<h3 id="DoNotDisturb">Do Not Disturb mode</h3>
276
277<p>The L Developer Preview introduces a new <em>Do Not Disturb</em> mode. When
278the user puts the device in <em>Do Not Disturb</em> mode, the device limits
279the frequency of the notifications it shows the user (when the user
280wants to avoid distractions). The user can
281customize the feature in a number of ways, such as:</p>
Robert Ly20555292014-06-13 23:28:19 -0700282
283<ul>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700284 <li>Specifying important people, whose calls should go through even when
285 the device is in <em>Do Not Disturb</em> mode.</li>
286 <li>Setting custom categories to allow notifications when the device is in
287 <em>Do Not Disturb</em> mode. Examples of such categories include phone
288 calls and direct communications (like Hangouts and Skype calls).</li>
289 <li>Setting rules so <em>Do Not Disturb</em> automatically goes into effect in
290 certain conditions (like at particular times of day).</li>
291</ul>
292
293<p>You should add the appropriate metadata to your app notifications to help
294make sure <em>Do Not Disturb</em> mode handles them properly. For example, if
295your app is an alarm clock,
296you can tag the notification as an alarm so it will wake the user up even if the
297device is in <em>Do Not Disturb</em> mode. For more information, see <a
298href="NotificationsMetadata">Notifications metadata</a>.</p>
299
300<h3 id="NotificationsMetadata">Notifications metadata</h3>
301<p>The L Developer Preview uses metadata associated with your app notifications
302to sort the notifications more intelligently. The metadata you set also
303controls how the system presents your app notifications when the user is in <em>Do
304Not Disturb</em> mode. To set the metadata, call the following methods in
305{@code android.app.Notification.Builder} when you construct the
306notification:</p>
307
308<ul>
309<li>{@code setCategory()}. Depending on the message category, this tells
310the system how to handle your app notifications when the device is
311in <em>Do Not Disturb</em> mode (for example, if your notification represents an
312incoming call, instant message, or alarm).
Robert Ly20555292014-06-13 23:28:19 -0700313<li>{@code setPriority()}. Notifications with the priority field set to
314{@code PRIORITY_MAX} or {@code PRIORITY_HIGH} will appear in a small floating
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700315window if the notification also has sound or vibration.</li>
Robert Ly20555292014-06-13 23:28:19 -0700316<li>{@code addPerson()}. Allows you to add a list of people to a notification.
317Your app can use this to signal to the system that it should group together
318notifications from the specified people, or rank notifications from these
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700319people as being more important.</li>
Robert Ly20555292014-06-13 23:28:19 -0700320</ul>
321
Ricardo Cerverad3e426b2014-06-15 16:01:28 -0700322<h3 id="Recents">Concurrent documents and activities in the Recents screen</h3>
Robert Ly20555292014-06-13 23:28:19 -0700323
324<p>In previous releases, the
325<a href="{@docRoot}design/get-started/ui-overview.html">Recents screen</a>
326could only display a single task for each app that the user interacted with
Andrew Solovay68990cf2014-06-15 20:26:07 -0700327most recently. The L Developer Preview enables your app to open more tasks as
328needed for additional concurrent activities for documents.
329This feature facilitates multitasking
Robert Ly20555292014-06-13 23:28:19 -0700330by letting users quickly switch between individual activities and documents
Andrew Solovay68990cf2014-06-15 20:26:07 -0700331from the Recents screen, with a consistent switching experience across all apps.
332Examples of such concurrent tasks might include open tabs in a web
333browser app, documents in a productivity app, concurrent matches in
Robert Ly20555292014-06-13 23:28:19 -0700334a game, or chats in a messaging app. Your app can manage its tasks
335through the {@code android.app.ActivityManager.AppTask} class.</p>
336
337<p>To insert a logical break so that the system treats your activity as a new
Andrew Solovay68990cf2014-06-15 20:26:07 -0700338task, use {@code android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT} when
Robert Ly20555292014-06-13 23:28:19 -0700339launching the activity with {@link android.app.Activity#startActivity(android.content.Intent) startActivity()}. You can also get this behavior by declaring the
340<a href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a>
341attribute {@code documentLaunchMode="intoExisting"} or {@code ="always"} in your
342manifest.</p>
343
344<p>You can also mark that a task should be removed from the Recents screen
Andrew Solovay68990cf2014-06-15 20:26:07 -0700345when all its activities are closed. To do this, use {@code
346android.content.Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS} when starting the
347root activity for
Robert Ly20555292014-06-13 23:28:19 -0700348the task. You can also set this behavior for an activity by declaring the
349<a href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a>
350attribute {@code autoRemoveFromRecents=“true”} in your manifest.</p>
351
352<p>To avoid cluttering the Recents screen, you can set the maximum number of
Andrew Solovay68990cf2014-06-15 20:26:07 -0700353tasks from your app that can appear in that screen. To do this, set the
354<a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a>
355attribute {@code android:maxRecent}. The current maximum that can be specified
Robert Ly20555292014-06-13 23:28:19 -0700356is 100 tasks per user.</a></p>
357
358<h3 id="WebView">WebView updates</h3>
359<p>The L Developer Preview updates the {@link android.webkit.WebView}
360implementation to Chromium M36, bringing security and stability enhancements,
361as well as bug fixes. The default user-agent string for a
362{@link android.webkit.WebView} running on the L Developer Preview has
363been updated to incorporate 36.0.0.0 as the version number.</p>
364
365<p>Additionally, this release brings support for the
366<a href="https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html">WebAudio</a>, <a href="https://www.khronos.org/webgl/">WebGL</a>, and
367<a href="http://www.webrtc.org/">WebRTC</a> open standards. To learn more about
368the new features included in this release, see <a href="https://developer.chrome.com/multidevice/webview/overview">WebView for Android</a>.</p>
369
370<h2 id="UserInput">User Input</h2>
371
372<h3 id="IME">IME bug fixes and improvements</h3>
373
374<p>Beginning in the L Developer Preview, users can more easily switch between
Andrew Solovay68990cf2014-06-15 20:26:07 -0700375all <a href="{@docRoot}guide/topics/text/creating-input-method.html">input
376method editors (IME)</a> supported by the platform. Performing the designated
Robert Ly20555292014-06-13 23:28:19 -0700377switching action (usually touching a Globe icon on the soft keyboard) will cycle
378among all such IMEs. This change takes place in
Andrew Solovay68990cf2014-06-15 20:26:07 -0700379{@link android.view.inputmethod.InputMethodManager#shouldOfferSwitchingToNextInputMethod
380InputMethodManager.shouldOfferSwitchingToNextInputMethod()}.</p>
Robert Ly20555292014-06-13 23:28:19 -0700381
Andrew Solovay68990cf2014-06-15 20:26:07 -0700382<p>In addition, the framework now checks whether the next IME includes a
383switching mechanism at all (and, thus, whether that IME supports switching to
384the IME after it). An
Robert Ly20555292014-06-13 23:28:19 -0700385IME with a switching mechanism will not cycle to an IME without one. This
386change takes place in
Andrew Solovay68990cf2014-06-15 20:26:07 -0700387{@link android.view.inputmethod.InputMethodManager#switchToNextInputMethod
388InputMethodManager.switchToNextInputMethod}.
Robert Ly20555292014-06-13 23:28:19 -0700389
390<p>To see an example of how to use the updated IME-switching APIs, refer to the
391updated soft-keyboard implementation sample in this release.</p>
392
393<h2 id="Animations">Animation &amp; Graphics</h2>
394
395<h3 id="OpenGLES-3-1">Support for OpenGL ES 3.1</h3>
396<p>The L Developer Preview adds Java interfaces and native support for OpenGL
397ES 3.1. Key new functionality provided in OpenGL ES 3.1 includes:</p>
398
399<ul>
400<li>Compute shaders
401<li>Separate shader objects
402<li>Indirect draw commands
403<li>Enhanced texturing functionality
404<li>Shading language improvements
405<li>Optional extensions for per-sample shading, advanced blending modes, and more
406<li>Backward compatibility with OpenGL ES 2.0 and 3.0
407</ul>
408
409<p>The Java interface for OpenGL ES 3.1 on Android is provided with GLES31. When using OpenGL ES 3.1, be sure that you declare it in your manifest file with the
410<a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a> tag and the {@code android:glEsVversion} attribute. For example:</p>
411
412<pre>
413&lt;manifest&gt;
414 &lt;uses-feature android:glEsVersion="0x00030001" /&gt;
415 ...
416&lt;/manifest&gt;
417</pre>
418
Andrew Solovay68990cf2014-06-15 20:26:07 -0700419<p>For more information about using OpenGL ES, including how to check the device’s supported OpenGL ES version at runtime, see the <a href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL ES API guide</a>.</p>
Robert Ly20555292014-06-13 23:28:19 -0700420
421<h2 id="Multimedia">Multimedia</h2>
422
Andrew Solovay68990cf2014-06-15 20:26:07 -0700423<h3 id="Camera-v2">Camera v2 API</h3>
Robert Ly20555292014-06-13 23:28:19 -0700424
425<p>The L Developer Preview introduces the new {@code android.hardware.camera2}
Andrew Solovay68990cf2014-06-15 20:26:07 -0700426API to facilitate fine-grain photo capture and image processing. You can now
427programmatically access the camera devices available to the system with {@code
428CameraManager.getCameraIdList()} and connect to a specific device with {@code
429CameraManager.openCamera()}. To start capturing images, create a {@code
430CameraCaptureSession} and specify the {@link android.view.Surface} objects for
431the captured images. The {@code CameraCaptureSession} can be configured to take
432single shots or multiple images in a burst.</p>
Robert Ly20555292014-06-13 23:28:19 -0700433
434<p>To be notified when new images are captured, implement the
435{@code CameraCaptureSession.CaptureListener()} interface and set it in your
436capture request. Now when the system completes the image capture request, your
437{@code CameraCaptureSession.CaptureListener()} receives a call to
438{@code onCaptureCompleted()}, providing you with the image capture metadata in a
439{@code CaptureResult}.</p>
440
441<h3 id="AudioPlayback">Audio playback</h3>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700442<p>This release includes the following changes to
443 {@link android.media.AudioTrack}:</p>
Robert Ly20555292014-06-13 23:28:19 -0700444<ul>
445 <li>Your app can now supply audio data in floating-point format
446({@code android.media.AudioFormat.ENCODING_PCM_FLOAT}). This permits greater
447dynamic range, more consistent precision, and greater headroom. Floating-point arithmetic is especially useful during intermediate calculations. Playback
Andrew Solovay68990cf2014-06-15 20:26:07 -0700448end-points use integer format for audio data, and with lower bit-depth. (In the
449L Developer Preview, portions of the internal pipeline are not yet
450floating-point.)
451 <li>Your app can now supply audio data as a {@link java.nio.ByteBuffer}, in the same
452format as provided by {@link android.media.MediaCodec}.
Robert Ly20555292014-06-13 23:28:19 -0700453 <li>The {@code WRITE_NON_BLOCKING} option can simplify buffering and
454 multithreading for some apps.
455</ul>
456
457<h3 id="MediaPlaybackControl">Media playback control</h3>
458<p>You can now build your own media controller app with the new
459{@code android.media.session.MediaController} class, which provides
460simplified transport controls APIs that replace those in
Andrew Solovay68990cf2014-06-15 20:26:07 -0700461{@link android.media.RemoteControlClient}. The {@code MediaController} class
462allows thread-safe control of playback from a non-UI process, making it easier
Robert Ly20555292014-06-13 23:28:19 -0700463to control your media playback service from your app’s user interface.
464
465<p>You can also create multiple controllers to send playback commands,
466media keys, and other events to the same ongoing
467{@code android.media.session.MediaSession}. When you add a controller, you must
468call {@code MediaSession.getSessionToken()} to request an access
469token in order for your app to interact with the session.</p>
470
Andrew Solovay68990cf2014-06-15 20:26:07 -0700471<p>You can now send transport commands such as "play", "stop", "skip", and
Robert Ly20555292014-06-13 23:28:19 -0700472"set rating" by using {@code MediaController.TransportControls}. To handle
Andrew Solovay68990cf2014-06-15 20:26:07 -0700473in-bound media transport commands from controllers attached to the session,
474override the callback methods in
Robert Ly20555292014-06-13 23:28:19 -0700475{@code MediaSession.TransportControlsCallback}.</p>
476
477<p>You can also create rich notifications that allow playback control tied to a
Andrew Solovay68990cf2014-06-15 20:26:07 -0700478media session with the new {@code android.app.Notification.MediaStyle} class. By
479using the new notification and media APIs, you will ensure that the System UI
480knows about your playback and can extract and show album art.</p>
Robert Ly20555292014-06-13 23:28:19 -0700481
482<h2 id="Storage">Storage</h2>
483
484<h3 id="DirectorySelection">Directory selection</h3>
485
486<p>The L Developer Preview extends the <a href="{@docRoot}guide/topics/providers/document-provider.html">Storage Access Framework</a> to let users
487select an entire directory, rather than individual files, to give your app
488read/write access to media files. When a directory is selected, your app also
489has access to all its child directories and content.</p>
490
491<p>To get the absolute paths to directories on external storage devices where
Andrew Solovay68990cf2014-06-15 20:26:07 -0700492applications can store media files, call the new
493{@code android.content.Context.getExternalMediaDirs()} method. No
494additional
Robert Ly20555292014-06-13 23:28:19 -0700495permissions are needed by your app to read or write to the returned paths.
Andrew Solovay68990cf2014-06-15 20:26:07 -0700496In this context, "external storage devices" are those devices which the system
497considers to be a
Robert Ly20555292014-06-13 23:28:19 -0700498permanent part of the device, and includes emulated external storage and
499physical media slots such as SD cards in battery compartments.</p>
500
501<p>If you want to access a document in an existing directory, call the
Andrew Solovay68990cf2014-06-15 20:26:07 -0700502{@code android.provider.DocumentsContract.buildDocumentViaUri()} method.
503Pass the method a URI representing the path to the parent directory, and the
504target document
505ID. The method returns a new {@link android.net.Uri} which your app can
Robert Ly20555292014-06-13 23:28:19 -0700506use to write media content with {@code DocumentsContract.createDocument()}.
507
508<h2 id="Wireless">Wireless &amp; Connectivity</h2>
509
510<h3 id="Multinetwork">Dynamic network selection and seamless handoff</h3>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700511<p>The L Developer Preview provides new multi-networking APIs. These let your app
Robert Ly20555292014-06-13 23:28:19 -0700512dynamically scan for available networks with specific capabilities, and
513establish a connection to them. This is useful when your app requires a
514specialized network, such as an SUPL, MMS, or carrier-billing network, or if
515you want to send data using a particular type of transport protocol.</p>
516
Andrew Solovay68990cf2014-06-15 20:26:07 -0700517<p>To select and connect to a network dynamically from your app follow these
518steps:</p>
519
520<ol>
521 <li>Create a {@link android.net.ConnectivityManager}.</li>
522 <li>Create a
523 {@code android.net.NetworkRequest} to specify the network features and transport
524 type your app is interested in.</li>
525 <li>To scan for suitable networks, call
526 {@code ConnectivityManager.requestNetwork()} or
527 {@code ConnectivityManager.registerNetworkCallback()}, and pass in the
528 {@code NetworkRequest} object and an implementation of
529 {@code ConnectivityManager.NetworkCallbackListener}.</li>
530
531</ol>
Robert Ly20555292014-06-13 23:28:19 -0700532
533<p>When the system detects a suitable network, it connects to the network and
534invokes the {@code NetworkCallbackListener.onAvailable()} callback. You can use
535the {@code android.net.Network} object from the callback to get additional
Andrew Solovay68990cf2014-06-15 20:26:07 -0700536information about the network, or to direct traffic to use the selected
537network.</p>
Robert Ly20555292014-06-13 23:28:19 -0700538
539<h3 id="BluetoothBroadcasting">Bluetooth broadcasting</h3>
540<p>Android 4.3 introduced platform support for <a href="{@docRoot}guide/topics/connectivity/bluetooth-le.html">Bluetooth Low Energy</a>
541(BLE) in the central role. In the L Developer Preview, an Android device can now
Andrew Solovay68990cf2014-06-15 20:26:07 -0700542act as a Bluetooth LE <em>peripheral device</em>. Apps can use this capability
543to make their presence known to
Robert Ly20555292014-06-13 23:28:19 -0700544nearby devices. For instance, you can build apps that allow a device to
545function as a pedometer or health monitor and communicate its data with another
546BLE device.</p>
547
548<p>The new {@code android.bluetooth.le} APIs enable your apps to broadcast advertisements, scan for responses, and form connections with nearby BLE devices.
549You must add the {@code android.permission.BLUETOOTH_ADMIN} permission in your
550manifest in order for your app to use the new advertising and scanning features.</a>
551
Andrew Solovay68990cf2014-06-15 20:26:07 -0700552<p>To begin Bluetooth LE advertising so that other devices can discover
553your app, call {@code android.bluetooth.le.BluetoothAdvertiser.startAdvisertising()}
554and pass in an implementation of the
555{@code android.bluetooth.le.AdvertiseCallback} class. The callback object
556receives a report of the success or failure of the advertising operation.</p>
Robert Ly20555292014-06-13 23:28:19 -0700557
Andrew Solovay68990cf2014-06-15 20:26:07 -0700558<p> The L Developer Preview introduces the {@code
559android.bluetooth.le.ScanFilter} class so that your app can scan for only the
560specific types of devices it is interested in. To begin scanning for Bluetooth
561LE devices, call {@code android.bluetooth.le.BluetoothLeScanner.startScan()} and
562pass in a list of filters. In the method call, you must also provide an
Robert Ly20555292014-06-13 23:28:19 -0700563implementation of {@code android.bluetooth.le.ScanCallback} to report if a
Andrew Solovay68990cf2014-06-15 20:26:07 -0700564Bluetooth LE advertisement is found. </p>
Robert Ly20555292014-06-13 23:28:19 -0700565
566<h3 id="NFCEnhancements">NFC enhancements</h3>
567<p>The L Developer Preview adds these enhancements to enable wider and more
568flexible use of NFC:</p>
569
570<ul>
571<li>Android Beam is now available in the share menu.
572<li>Your app can invoke the Android Beam on the user’s device to share data by
573calling {@code android.nfc.NfcAdapter.invokeBeam()}. This avoids the need for
574the user to manually tap the device against another NFC-capable device to
575complete the data transfer.
Andrew Solovay68990cf2014-06-15 20:26:07 -0700576<li>You can use the new {@code android.nfc.NdefRecord.createTextRecord()} method
577to create an NDEF record containing UTF-8 text data.
Robert Ly20555292014-06-13 23:28:19 -0700578<li>If you are developing a payment app, you now have the ability to
579register an NFC application ID (AID) dynamically by calling
580{@code android.nfc.cardemulation.CardEmulation.registerAidsForService()}.
581You can also use {@code android.nfc.cardemulation.CardEmulation.setPreferredService()}
582to set the preferred card emulation service that should be used when a specific
583activity is in the foreground.
584</ul>
585
586<h2 id="Power">Power Efficiency</h2>
587
588<h3 id="JobScheduler">Scheduling jobs</h3>
589<p>The L Developer Preview provides a new {@code android.app.job.JobScheduler}
Quddus Chongd50a6f82014-06-15 12:13:18 -0700590API that lets you optimize battery life by defining jobs for the system to run
Andrew Solovay68990cf2014-06-15 20:26:07 -0700591asynchronously at a later time or under specified conditions (such as when the
592device is charging). This is useful in such situations as:</p>
593<ul>
594 <li>The app has non-user-facing work that you want to defer until the unit is
595 plugged in.</li>
596 <li>The app has a task that requires network access (or requires a wifi
597 connection).</li>
598 <li>The app has a number of tasks that you want to run as a batch on a regular
599 schedule.</li>
Robert Ly20555292014-06-13 23:28:19 -0700600
Andrew Solovay68990cf2014-06-15 20:26:07 -0700601</ul>
602
603<p>A unit of work is encapsulated by a {@code android.app.job.JobInfo} object.
604This object provides an exact description of the criteria to be used for
605scheduling.</p>
Robert Ly20555292014-06-13 23:28:19 -0700606
607<p>Use the {@code android.app.job.JobInfo.Builder} to configure how the
608scheduled task should run. You can schedule the task to run under specific
Andrew Solovay68990cf2014-06-15 20:26:07 -0700609conditions, such as:</p>
610
611<ul>
612 <li>The device is charging</li>
613 <li>The device is connected to an unmetered network</li>
614 <li>The system deems the device to be idle</li>
615</ul>
Robert Ly20555292014-06-13 23:28:19 -0700616
617<p>For example, you can add code like this to run your task on an
618unmetered network:</p>
619
620<pre>
621JobInfo uploadTask = new JobInfo.Builder(mJobId, mServiceComponent)
622 .setRequiredNetworkCapabilities(JobInfo.NetworkType.UNMETERED)
623 .build();
624
625JobScheduler jobScheduler =
626 (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE)
627jobScheduler.schedule(uploadTask);
628</pre>
629
630<h3 id="PowerMeasurementTools">Developer tools and APIs for power measurement</h3>
631<p>The L Developer Preview provides several new developer tools and APIs to help
632you better measure and understand your app's power usage.</p>
633
634<dl>
635<dt><strong>batterystats</strong></dt>
636<dd>
637<p>The {@code dumpsys batterystats} command allows you to generate interesting
638statistical data about battery usage on a device, organized by unique user ID
639(UID). The statistics generated by the tool include:</p>
640
641<ul>
642<li>History of battery related events
643<li>Global statistics for the device
644<li>Approximated power use per UID and system component
645<li>Per-app mobile ms per packet
646<li>System UID aggregated statistics
647<li>App UID aggregated statistics
648</ul>
649
Quddus Chongd50a6f82014-06-15 12:13:18 -0700650<p>Use the {@code --help} option to learn about the various options for
Andrew Solovay68990cf2014-06-15 20:26:07 -0700651tailoring the output. For example, to print battery usage
652statistics for a given app package since the device was last charged, run this
Quddus Chongd50a6f82014-06-15 12:13:18 -0700653command:
Robert Ly20555292014-06-13 23:28:19 -0700654<pre>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700655$ adb shell dumpsys batterystats --charged &lt;package-name&gt;
Robert Ly20555292014-06-13 23:28:19 -0700656</pre>
657</dd>
658
659<dt><strong>Battery Historian</strong></dt>
660<dd>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700661<p>The Battery Historian tool ({@code historian.par}) analyzes Android
662bug reports from the L Developer Preview and creates an HTML visualization of
663power-related events. It can
664also visualize power consumption data from a power monitor, and attempts to
665map power usage to the wake locks seen. You can find the Battery Historian tool
Robert Ly20555292014-06-13 23:28:19 -0700666in {@code &lt;sdk&gt;/tools}.</p>
667
Andrew Solovay68990cf2014-06-15 20:26:07 -0700668<img src="images/battery_historian.png"
669 srcset="images/battery_historian@2x.png 2x"
670 alt="" width="440" height="240"
671 id="figure1" />
672<p class="img-caption">
673 <strong>Figure 1.</strong>HTML visualization generated by the Battery
674 Historian tool.
675</p>
676
677<p>For best results, you should first enable full wake lock reporting, to allow
Robert Ly20555292014-06-13 23:28:19 -0700678the Battery Historian tool to monitor uninterrupted over an extended period of
679time:</p>
680<pre>
681$ adb shell dumpsys batterystats --enable full-wake-history
682</pre>
683
684<p>You should also reset battery statistics at the beginning of a
685measurement:</p>
686<pre>
687$ adb shell dumpsys batterystats --reset
688</pre>
689
690<p>To generate an HTML visualization:</p>
691<pre>
692$ historian.par [-p powerfile] bugreport.txt > out.html
693</pre>
694</dd>
695
Robert Ly20555292014-06-13 23:28:19 -0700696</dl>
697
698<h2 id="Enterprise">Enterprise</h2>
699<h3 id="ManagedProvisioning">Managed provisioning</h3>
700
Andrew Solovay68990cf2014-06-15 20:26:07 -0700701<div class="figure" style="width:360px">
702 <img src="images/managed_apps_launcher.png"
703 srcset="images/managed_apps_launcher@2x.png 2x"
704 alt="" width="360" height="572" id="figure2" />
705 <p class="img-caption">
706 <strong>Figure 2.</strong> Launcher screen showing managed apps (marked with
707 a lock badge)
708 </p>
709</div>
710
Robert Ly20555292014-06-13 23:28:19 -0700711<p>The L Developer Preview provides new functionality for running apps within
712an enterprise environment:</p>
713<ul>
714<li><strong>Create managed user profiles</strong>. A device administrator can
Andrew Solovay68990cf2014-06-15 20:26:07 -0700715initiate a managed provisioning process to add a co-present but separate managed
716profile to a device with an existing personal account. The administrator has
717control over the managed profile.</li>
718<li><strong>Set device owner</strong>. Device administrators can also initiate a
719managed provisioning process to automatically provision a
720currently-unprovisioned device such that they have full control over the
721device.</li>
Robert Ly20555292014-06-13 23:28:19 -0700722</ul>
723
Andrew Solovay68990cf2014-06-15 20:26:07 -0700724<p>To start the managed provisioning process, send {@code
725ACTION_PROVISION_MANAGED_PROFILE} in an {@link android.content.Intent}. If the
726call is successful, the system triggers the {@code
727android.app.admin.DeviceAdminReceiver. onProfileProvisioningComplete()} callback.
728You can then call {@code app.admin.DevicePolicyManager. setProfileEnabled()} to
729set this profile to the enabled state.</p>
730
731<p>A user may be associated with more than one managed profile. To get a list of
732the managed profiles associated with the user, call
733{@code android.os.UserManager. getUserProfiles()}.</p>
Robert Ly20555292014-06-13 23:28:19 -0700734
735<p>Once a managed profile is created for a user, apps that are managed by the
736device administrator will appear alongside non-managed apps in the user’s
Andrew Solovay68990cf2014-06-15 20:26:07 -0700737Launcher, Recent apps screen, and notifications.</p>
Robert Ly20555292014-06-13 23:28:19 -0700738
Andrew Solovay68990cf2014-06-15 20:26:07 -0700739<p>If you are developing a Launcher app, you can use the new {@code
740android.content.pm.LauncherApps} class to get a list of launchable activities
741for the current user and any associated managed profiles. Your Launcher can make
742the managed apps visually prominent by appending a “work” badge to the icon
743drawable with {@code android.os.UserManager.getBadgeDrawableForUser()}.</p>
Robert Ly20555292014-06-13 23:28:19 -0700744
745<h2 id="Printing">Printing Framework</h2>
746
747<h3 id="PDFRender">Render PDF as bitmap</h3>
748<p>You can now render PDF document pages into bitmap images for printing by
749using the new {@code android.graphics.pdf.PdfRenderer} class. You must specify a
Andrew Solovay68990cf2014-06-15 20:26:07 -0700750{@link android.os.ParcelFileDescriptor} that is seekable (that is, the content can be randomly
Robert Ly20555292014-06-13 23:28:19 -0700751accessed) on which the system writes the the printable content. Your app can
752obtain a page for rendering with {@code openPage()}, then call {@code render()}
753to turn the opened {@code PdfRenderer.Page} into a bitmap. You can also set
Andrew Solovay68990cf2014-06-15 20:26:07 -0700754additional parameters if you only want to convert a portion of the document into
Robert Ly20555292014-06-13 23:28:19 -0700755a bitmap image (for example, to implement <a href="http://en.wikipedia.org/wiki/Tiled_rendering">tile rendering</a> in order to zoom in on the document).</p>
756
757<h2 id="TestingA11y">Testing &amp; Accessibility </h2>
758
Andrew Solovay68990cf2014-06-15 20:26:07 -0700759<h3 id="TestingA11yImprovements">Testing and accessibility improvements</h3>
Robert Ly20555292014-06-13 23:28:19 -0700760<p>The L Developer Preview adds the following support for testing and
761accessibility:</p>
762
763<ul>
764<li>You can use the new {@code android.app.UiAutomation.getWindowAnimationFrameStats()}
765and {@code android.app.UiAutomation.getWindowContentFrameStats()} methods to
766capture frame statistics for window animations and content. This lets you
767write instrumentation tests to evaluate if the app under test is rendering
768frames at a sufficient refresh frequency to provide a smooth user experience.
Andrew Solovay68990cf2014-06-15 20:26:07 -0700769
Robert Ly20555292014-06-13 23:28:19 -0700770<li>You can execute shell commands from your instrumentation test with the new
771{@code android.app.UiAutomation.executeShellCommand()}. The command execution
Andrew Solovay68990cf2014-06-15 20:26:07 -0700772is similar to running {@code adb shell} from a host connected to the device. This
Robert Ly20555292014-06-13 23:28:19 -0700773allows you to use shell based tools such as {@code dumpsys}, {@code am},
774{@code content}, and {@code pm}.
Andrew Solovay68990cf2014-06-15 20:26:07 -0700775
Robert Ly20555292014-06-13 23:28:19 -0700776<li>Accessibility services and test tools that use the accessibility APIs
Andrew Solovay68990cf2014-06-15 20:26:07 -0700777(such as <a href="{@docRoot}tools/help/uiautomator/index.html">uiautomator</a>)
Robert Ly20555292014-06-13 23:28:19 -0700778can now retrieve detailed information about the properties of windows on the
779screen that sighted users can interact with. To retrieve a list of
Andrew Solovay68990cf2014-06-15 20:26:07 -0700780{@code android.view.accessibility.AccessibilityWindowInfo} objects
781representing the
Robert Ly20555292014-06-13 23:28:19 -0700782windows information, call the new
783{@code android.accessibilityservice.AccessibilityService.getWindows()} method.
784<li>You can use the new {@code android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction} to define standard or customized
Andrew Solovay68990cf2014-06-15 20:26:07 -0700785actions to perform on an {@link android.view.accessibility.AccessibilityNodeInfo}.
Robert Ly20555292014-06-13 23:28:19 -0700786The new {@code AccessibilityAction} class replaces the actions-related APIs
787previously found in {@code AccessibilityNodeInfo}.
788</ul>
789
Andrew Solovay68990cf2014-06-15 20:26:07 -0700790<h2 id="Manifest">Manifest Declarations</h2>
Robert Ly20555292014-06-13 23:28:19 -0700791
792<h3 id="ManifestFeatures">Declarable required features</h3>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700793<p>The following values are now supported in the <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a> element, so you
Robert Ly20555292014-06-13 23:28:19 -0700794can ensure that your app is installed only on devices that provide the features
795your app needs.</p>
796
797<ul>
Andrew Solovay68990cf2014-06-15 20:26:07 -0700798<li>{@code FEATURE_LEANBACK}. Declares that your app must be installed only on
799devices that support the <a href="{@docRoot}training/tv}">Android TV</a> user
800interface. Example:
Robert Ly20555292014-06-13 23:28:19 -0700801<pre>
802&lt;uses-feature android:name="android.software.leanback"
803 android:required="true" /&gt;
804</pre>
805
Andrew Solovay68990cf2014-06-15 20:26:07 -0700806<li>{@code FEATURE_WEBVIEW}. Declares that your app must only be installed on
807devices that fully implement the {@code android.webkit.*} APIs. Example:
Robert Ly20555292014-06-13 23:28:19 -0700808<pre>
809&lt;uses-feature android:name="android.software.webview"
810 android:required="true" /&gt;
811</pre>
812</ul>
813
814<h3 id="ManifestPermissions">User permissions</h3>
815<p>The following values are now supported in the <a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">{@code &lt;uses-permission&gt;}</a> to declare the
816permissions your app requires in order to access certain APIs.
817
818<ul>
819<li>{@code SIM_COMMUNICATION}. Required to communicate with a SIM card using
820 logical channels.
821</ul>