android-4.2.jd revision 66e642b6d0da26c366acabaf6e7290e0f7aec96a
1page.title=Android 4.2 APIs 2sdk.platform.version=4.2 3sdk.platform.apiLevel=17 4@jd:body 5 6<div id="qv-wrapper"> 7<div id="qv"> 8 9<h2>In this document</h2> 10<ol> 11 <li><a href="#Behaviors">Important Behavior Changes</a></li> 12 <li><a href="#Daydream">Daydream</a></li> 13 <li><a href="#SecondaryDisplays">Secondary Displays</a></li> 14 <li><a href="#Lockscreen">Lockscreen Widgets</a></li> 15 <li><a href="#MultipleUsers">Multiple Users</a></li> 16 <li><a href="#RTL">RTL Layout Support</a></li> 17 <li><a href="#NestedFragments">Nested Fragments</a></li> 18 <li><a href="#Renderscript">Renderscript</a></li> 19</ol> 20 21<h2>See also</h2> 22<ol> 23<li><a 24href="{@docRoot}sdk/api_diff/17/changes.html">API 25Differences Report »</a> </li> 26</ol> 27 28</div> 29</div> 30 31 32<p>API Level: 17</p> 33 34<p>Android 4.2 ({@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}) 35is an update to the Jelly Bean release that offers new features for users and app 36developers. This document provides an introduction to the most notable and 37useful new APIs for developers.</p> 38 39<p>As an app developer, you should download the Android 4.2 system image and SDK platform from 40the <a href="{@docRoot}tools/help/sdk-manager.html">SDK Manager</a> as soon as possible. If you 41don’t have a device running Android 4.2 on which to test your app, use the Android 4.2 system 42image to test your app on the <a href="{@docRoot}tools/devices/emulator.html">Android emulator</a>. 43Then build your apps against the Android 4.2 platform to begin using the latest APIs.</p> 44 45 46 47<div class="sidebox-wrapper"> 48<div class="sidebox"> 49 50<h3 id="ApiLevel">Declare your app API Level</h3> 51 52<p>To better optimize your app for devices running Android {@sdkPlatformVersion}, 53 you should set your <a 54href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> to 55<code>"{@sdkPlatformApiLevel}"</code>, install it on an Android {@sdkPlatformVersion} system image, 56test it, then publish an update with this change.</p> 57 58<p>You 59can use APIs in Android {@sdkPlatformVersion} while also supporting older versions by adding 60conditions to your code that check for the system API level before executing 61APIs not supported by your <a 62href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a>. 63To learn more about 64maintaining backward-compatibility, read <a 65href="{@docRoot}training/backward-compatible-ui/index.html">Creating Backward-Compatible 66UIs</a>.</p> 67 68<p>More information about how API levels work is available in <a 69href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">What is API 70Level?</a></p> 71 72</div> 73</div> 74 75 76 77 78<h2 id="Behaviors">Important Behavior Changes</h2> 79 80<p>If you have previously published an app for Android, be aware of the following 81changes that might affect your app’s behavior:</p> 82 83<ul> 84 <li><b>Content providers</b> are no longer exported by default. That is, the default value 85for the <a href="{@docRoot}guide/topics/manifest/provider-element.html#exported">{@code 86android:exported}</a> attribute is now {@code “false"}. If it’s important that other apps be 87able to access your content provider, you must now explicitly set <a 88href="{@docRoot}guide/topics/manifest/provider-element.html#exported">{@code 89android:exported="true"}.</a> 90 <p>This change takes effect only if you set either <a 91 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code 92android:targetSdkVersion}</a> or <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code 93android:minSdkVersion}</a> to 17 or higher. Otherwise, the default value is still {@code “true"} 94even when running on Android 4.2 and higher.</p> 95 </li> 96 97 <li>Compared to previous versions of Android, <b>user location</b> results may be less accurate 98if your app requests the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} permission but 99does not request the {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission. 100 <p>To meet the privacy expectations of users when your app requests permission for 101coarse location (and not fine location), the system will not provide a user location estimate 102that’s more accurate than a city block.</p> 103 </li> 104 105 <li>Some <b>device settings</b> defined by {@link android.provider.Settings.System} are now 106 read-only. If your app attempts to write changes to settings defined in {@link 107 android.provider.Settings.System} that have moved to {@link android.provider.Settings.Global}, 108 the write operation will silently fail when running on Android 4.2 and higher. 109 <p>Even if your value for <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code 110android:targetSdkVersion}</a> and <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code 111android:minSdkVersion}</a> is lower than 17, your app is not able to modify the settings that have 112moved to {@link android.provider.Settings.Global} when running on Android 4.2 and higher.</p> 113 </li> 114</ul> 115 116 117 118 119 120 121<h2 id="Daydream">Daydream</h2> 122 123<p>Daydream is a new interactive screensaver mode for Android devices. It activates automatically 124when the device is inserted into a dock or when the device is left idle while plugged in to a 125charger (instead of turning the screen off). Daydream displays one dream at a time, which may 126be a purely visual, passive display that dismisses upon touch, or may be interactive and responsive 127to the full suite of input events. Your dreams run in your app’s process and have full access to 128the Android UI toolkit, including views, layouts, and animations, so they are more flexible and 129powerful than either live wallpapers or app widgets.</p> 130 131<p>You can create a dream for Daydream by implementing a subclass of {@link 132android.service.dreams.DreamService}. The {@link android.service.dreams.DreamService} APIs are 133designed to be similar to those of {@link android.app.Activity}. To specify the UI for your 134dream, pass a layout resource ID or {@link android.view.View} to {@link 135android.service.dreams.DreamService#setContentView setContentView()} at any point after you have 136a window, such as from the {@link android.service.dreams.DreamService#onAttachedToWindow()} 137callback.</p> 138 139<p>The {@link android.service.dreams.DreamService} class provides other important lifecycle callback 140methods on top of the base {@link android.app.Service} APIs, such as {@link 141android.service.dreams.DreamService#onDreamingStarted()}, {@link 142android.service.dreams.DreamService#onDreamingStopped()}, and {@link 143android.service.dreams.DreamService#onDetachedFromWindow()}. 144You cannot initiate a {@link android.service.dreams.DreamService} from your 145app—it is launched automatically by the system.</p> 146 147<p>If your dream is interactive, you can start an activity from the dream to send the user into 148your app’s full UI for more detail or control. You can use {@link 149android.service.dreams.DreamService#finish()} to end the dream so the user can see the 150new Activity.</p> 151 152<p>To make your daydream available to the system, declare your {@link 153android.service.dreams.DreamService} with a <a 154href="{@docRoot}guide/topics/manifest/service-element.html">{@code <service>}</a> element 155in your manifest file. You must then include an intent filter with the action {@code 156"android.service.dreams.DreamService"}. For example:</p> 157 158<pre> 159<service android:name=".MyDream" android:exported="true" 160 android:icon="@drawable/dream_icon" android:label="@string/dream_label" > 161 <intent-filter> 162 <action android:name="android.service.dreams.DreamService" /> 163 <category android:name="android.intent.category.DEFAULT" /> 164 </intent-filter> 165</service> 166</pre> 167 168<p>There are some other useful methods in {@link android.service.dreams.DreamService} 169to be aware of:</p> 170 171<ul> 172 <li>{@link android.service.dreams.DreamService#setInteractive(boolean)} controls whether 173the dream receives input events or exits immediately upon user input. If the dream is 174interactive, the user may use the <em>Back</em> or <em>Home</em> buttons to exit the dream or you can call 175{@link android.service.dreams.DreamService#finish()} to stop the dream.</li> 176 <li>If you want a fully immersive display, you can call {@link 177android.service.dreams.DreamService#setFullscreen 178setFullscreen()} to hide the status bar.</li> 179 <li>Before Daydream starts, the display dims to signal to the user that the idle timeout 180is approaching. Calling {@link android.service.dreams.DreamService#setScreenBright 181setScreenBright(true)} allows you to instead set the display at its usual brightness.</li> 182</ul> 183 184<p>For more information, see the {@link android.service.dreams.DreamService} documentation.</p> 185 186 187 188 189 190 191 192 193 194 195 196<h2 id="SecondaryDisplays">Secondary Displays</h2> 197 198<p>Android now allows your app to display unique content on additional screens that are connected 199to the user’s device over either a wired connection or Wi-Fi. 200 To create unique content for a secondary display, extend the {@link android.app.Presentation} 201class and implement the {@link android.app.Presentation#onCreate onCreate()} callback. Within 202{@link android.app.Presentation#onCreate onCreate()}, specify your UI for the secondary display 203by calling {@link android.app.Presentation#setContentView setContentView()}. 204As an extension of the {@link android.app.Dialog} class, the {@link 205android.app.Presentation} class provides the region in which your app can display a unique UI on the 206secondary display.</p> 207 208<p>To detect secondary displays where you can display your {@link android.app.Presentation}, 209use either the {@link android.hardware.display.DisplayManager} or {@link android.media.MediaRouter} 210APIs. While the {@link android.hardware.display.DisplayManager} APIs allow you to enumerate 211multiple displays that may be connected at once, you should usually use {@link 212android.media.MediaRouter} instead to quickly access the system’s default display for 213presentations.</p> 214 215<p>To get the default display for your presentation, call {@link 216android.media.MediaRouter#getSelectedRoute MediaRouter.getSelectedRoute()} and pass it 217{@link android.media.MediaRouter#ROUTE_TYPE_LIVE_VIDEO}. This returns a {@link 218android.media.MediaRouter.RouteInfo} object that describes the system’s currently selected route 219for video presentations. If the {@link android.media.MediaRouter.RouteInfo} is not null, call 220{@link android.media.MediaRouter.RouteInfo#getPresentationDisplay()} to get the {@link 221android.view.Display} representing the connected display.</p> 222 223<p>You can then display your presentation by passing the {@link android.view.Display} object 224to a constructor for your {@link android.app.Presentation} class. Your presentation will now 225appear on the secondary display.</p> 226 227<p>To detect at runtime when a new display has been connected, create an instance of {@link 228android.media.MediaRouter.SimpleCallback} in which you implement the {@link 229android.media.MediaRouter.SimpleCallback#onRoutePresentationDisplayChanged 230onRoutePresentationDisplayChanged()} callback method, which the system will call when a new 231presentation display is connected. Then register the {@link 232android.media.MediaRouter.SimpleCallback} by passing it to {@link 233android.media.MediaRouter#addCallback MediaRouter.addCallback()} along with the {@link 234android.media.MediaRouter#ROUTE_TYPE_LIVE_VIDEO} route type. When you receive a call to 235{@link android.media.MediaRouter.SimpleCallback#onRoutePresentationDisplayChanged 236onRoutePresentationDisplayChanged()}, simply call {@link 237android.media.MediaRouter#getSelectedRoute MediaRouter.getSelectedRoute()} as mentioned above.</p> 238 239<p>To further optimize the UI in your {@link android.app.Presentation} for 240secondary screens, you can apply 241a different theme by specifying the {@link 242android.R.attr#presentationTheme android:presentationTheme} attribute in the <a 243href=”{@docRoot}guide/topics/resources/style-resource.html”>{@code <style>}</a> that you’ve 244applied to your application or activity.</p> 245 246<p>Keep in mind that screens connected to the user’s device often have a larger screen size and 247likely a different screen density. Because the screen characteristics may different, you should 248provide resources that are optimized specifically for such larger displays. If you need 249to request additional resources from your {@link 250android.app.Presentation}, call {@link android.app.Presentation#getContext()}{@link 251android.content.Context#getResources .getResources()} to get the {@link 252android.content.res.Resources} object corresponding to the display. This provides 253the appropriate resources from your app that are best suited for the 254secondary display's screen size and density.</p> 255 256<p>For more information and some code samples, see the {@link android.app.Presentation} 257class documentation.</p> 258 259 260 261 262 263 264 265 266 267 268<h2 id="Lockscreen">Lockscreen Widgets</h2> 269 270<p>Android now allows users to add app widgets to the lock screen. To make your <a 271href="{@docRoot}guide/topics/appwidgets/index.html">App Widget</a> available for use on the 272lock screen, add the {@link android.appwidget.AppWidgetProviderInfo#widgetCategory 273android:widgetCategory} attribute to your XML file that specifies the {@link 274android.appwidget.AppWidgetProviderInfo}. This attribute supports two values: {@code home_screen} 275and {@code keyguard}. By default, the attribute is set to {@code home_screen} so users can add your 276app widget to the Home screen. If you want your app widget to be also available on the lock 277screen, add the {@code keyguard} value:</p> 278 279<pre> 280<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" 281 ... 282 android:widgetCategory="keyguard|home_screen"> 283</appwidget-provider> 284</pre> 285 286<p>You should also specify an initial layout for your app widget when on the lock screen with 287the {@link android.appwidget.AppWidgetProviderInfo#initialKeyguardLayout 288android:initialKeyguardLayout} attribute. This works the same way as the {@link 289android.appwidget.AppWidgetProviderInfo#initialLayout android:initialLayout}, in that it provides 290a layout that can appear immediately until your app widget is initialized and able to update the 291layout.</p> 292 293<p>For more information about building app widgets for the lock screen, including to properly 294size your app widget when on the lock screen, see the <a 295href="{@docRoot}guide/topics/appwidgets/index.html#lockscreen">App Widgets</a> guide.</p> 296 297 298 299 300 301 302 303<h2 id="MultipleUsers">Multiple Users</h2> 304 305<p>Android now allows multiple user spaces on shareable devices such as tablets. Each user on a 306device has his or her own set of accounts, apps, system settings, files, and any other 307user-associated data.</p> 308 309<p>As an app developer, there’s nothing different you need to do in order for your app to work 310properly with multiple users on a single device. Regardless of how many users may exist on a 311device, the data your app saves for a given user is kept separate from the data your app saves 312for other users. The system keeps track of which user data belongs to the user process in which 313your app is running and provides your app access to only that user’s data and does not allow 314access to other users’ data.</p> 315 316<h3>Saving data in a multi-user environment</h3> 317 318<p>Whenever your app saves user preferences, creates a database, or writes a file to the user’s 319internal or external storage space, that data is accessible only while running as that user.</p> 320 321<p>To be certain that your app behaves properly in a multi-user environment, do not refer to your 322internal app directory or external storage location using hard-coded paths and instead always use 323the appropriate APIs:</p> 324<ul> 325 <li>For access to internal storage, use {@link android.content.Context#getFilesDir()}, {@link 326android.content.Context#getCacheDir()}, or {@link android.content.Context#openFileOutput 327openFileOutput()}.</li> 328 <li>For access to external storage, use {@link android.content.Context#getExternalFilesDir 329 getExternalFilesDir()} or {@link android.os.Environment#getExternalStoragePublicDirectory 330 getExternalStoragePublicDirectory()}. 331</ul> 332 333<p>No matter which of these APIs you use to save data for a given user, the data will not be 334accessible while running as a different user. From your app’s point of view, each user is running 335on a completely separate device.</p> 336 337<h3>Identifying users in a multi-user environment</h3> 338 339<p>If your app wants to identify unique users such as to gather analytics or create other account 340associations, you should follow the recommended practices for <a 341href="http://android-developers.blogspot.com/2011/03/identifying-app-installations.html">identifying 342unique installations</a>. By creating a new {@link java.util.UUID} when your app starts for the 343first time, you’re certain to obtain a unique ID for tracking each user, regardless of how many 344users install your app on a single device. Alternatively, you can save a local token fetched from 345your server or use the registrations ID provided by <a 346href="{@docRoot}guide/google/gcm/index.html">Google Cloud Messaging</a>.</p> 347 348<p>Beware that if your app requests one of the hardware device identifiers (such as the WiFi MAC 349address, the {@link android.os.Build#SERIAL} number, or the {@link 350android.provider.Settings.Secure#ANDROID_ID} number), they will provide the same value for each 351user because these identifiers are tied to the hardware and not the user. Not to mention the other 352problems these identifiers introduce as discussed in the <a 353href="http://android-developers.blogspot.com/2011/03/identifying-app-installations.html">Identifying 354App Installations</a> blog post.</p> 355 356<h3>New Global Settings</h3> 357 358<p>The system settings have been updated to support multiple users with the addition of {@link 359android.provider.Settings.Global}. This collection of settings is similar to {@link 360android.provider.Settings.Secure} settings because they are read-only, but applies globally across 361all user spaces on the device.</p> 362 363<p>Several existing settings were relocated here from either {@link 364android.provider.Settings.System} or {@link android.provider.Settings.Secure}. If your app is 365currently making changes to settings previously defined in {@link android.provider.Settings.System} 366(such as {@link android.provider.Settings.System#AIRPLANE_MODE_ON}), then you should expect that 367doing so will no longer work on a device running Android 4.2 or higher if those settings were 368moved to {@link android.provider.Settings.Global}. You can continue to read settings that are in 369{@link android.provider.Settings.Global}, but because the settings are no longer considered safe 370for apps to change, attempting to do so will fail silently and the system will write a warning to 371the system log when running your app on Android 4.2 or higher.</p> 372 373 374 375 376 377 378 379 380 381<h2 id="RTL">RTL Layout Support</h2> 382 383<p>Android now offers several APIs that allow you to build user interfaces that gracefully 384transform layout orientation to support languages that use right-to-left (RTL) UIs and reading 385direction, such as Arabic and Hebrew.</p> 386 387<p>To begin supporting RTL layouts in your app, set the {@link android.R.attr#supportsRtl 388android:supportsRtl} attribute to the {@code <application>} element in your manifest file 389and set it {@code “true"}. Once you enable this, the system will enable various RTL APIs to 390display your app with RTL layouts. For instance, the action bar will show the icon and title 391on the right side and action buttons on the left, and any layouts you’ve created with the 392framework-provided {@link android.view.View} classes will also be reversed.</p> 393 394<p>If you need to further optimize the appearance of your app when displayed with an RTL layout, 395there are two basic levels of optimization:</p> 396 397<ol> 398 <li>Convert left- and right-oriented layout properties to start- and end-oriented layout 399properties. 400 <p>For example, use {@link android.R.attr#layout_marginStart android:layout_marginStart} 401in place of {@code android:layout_marginLeft} and {@link android.R.attr#layout_marginEnd 402android:layout_marginEnd} in place of {@code android:layout_marginRight}. 403 <p>The {@link android.widget.RelativeLayout} class also provides the corresponding layout 404attributes to replace left/right positions, such as {@code android:layout_alignParentStart} to 405replace {@code android:layout_alignParentLeft} and {@code android:layout_toStartOf} instead of 406{@code android:layout_toLeftOf}. 407 </li> 408 <li>Or to provide complete optimization for RTL layouts, you can provide entirely separate 409layout files using the {@code ldrtl} resource qualifier ({@code ldrtl} stands for 410layout-direction-right-to-left}). For example, you can save your default layout files in 411{@code res/layout/} and your RTL optimized layouts in {@code res/layout-ldrtl/}. 412 <p>The {@code ldrtl} qualifier is great for drawable resources, so that you can provide 413graphics that are oriented in the direction corresponding to the reading direction.</p> 414 </li> 415</ol> 416 417<p>Various other APIs are available across the framework to support RTL layouts, such as in 418the {@link android.view.View} class so that you can implement the proper behaviors for custom 419views and in {@link android.content.res.Configuration} to query the current layout direction.</p> 420 421<p><strong>Note:</strong> If you are using SQlite and have tables or column names that are 422“number only," be 423careful: using <a href="{@docRoot}reference/java/lang/String.html#format(String, Object...)">{@code 424String.format(String, Object...)}</a> can lead to errors where the numbers 425have been converted to their Arabic equivalents if your device has been set to the Arabic locale. 426You must use <a href="{@docRoot}reference/java/lang/String.html#format(Locale,String,Object...)">{@code 427String.format(Locale,String,Object...)}</a> to ensure numbers are 428preserved as ASCII. Also use <a href="{@docRoot}reference/java/lang/String.html#format(String,int)">{@code 429String.format("%d", int)}</a> instead of using 430<a href="{@docRoot}reference/java/lang/String.html#valueOf(int)">{@code String.valueOf(int)}</a> for 431formatting numbers.</p> 432 433 434 435 436 437 438 439 440 441 442 443 444 445<h2 id="NestedFragments">Nested Fragments</h2> 446 447<p>You can now embed fragments inside fragments. This is useful for a variety of situations in 448which you want to place dynamic and re-usable UI components into a UI component that is itself 449dynamic and re-usable. For example, if you use {@link android.support.v4.view.ViewPager} to 450create fragments that swipe left and right and consume a majority of the screen space, you can 451now insert fragments into each fragment page.</p> 452 453<p>To nest a fragment, simply call {@link android.app.Fragment#getChildFragmentManager()} on 454the {@link android.app.Fragment} in which you want to add a fragment. This returns a {@link 455android.app.FragmentManager} that you can use like you normally do from the top-level activity 456to create fragment transactions. For example, here’s some code that adds a fragment from within 457an existing {@link android.app.Fragment} class:</p> 458 459<pre> 460Fragment videoFragment = new VideoPlayerFragment(); 461FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); 462transaction.add(R.id.video_fragment, videoFragment).commit(); 463</pre> 464 465<p>From within a nested fragment, you can get a reference to the parent fragment by calling 466{@link android.app.Fragment#getParentFragment()}.</p> 467 468<p>The Android Support Library also now supports nested fragments, so you can implement nested 469fragment designs on Android 1.6 and higher.</p> 470 471<p><strong>Note:</strong> You cannot inflate a layout into a fragment when that layout 472includes a {@code <fragment>}. Nested fragments are only supported when added to a 473fragment dynamically.</p> 474 475 476 477 478 479 480<h2 id="Renderscript">Renderscript</h2> 481 482<p>Renderscript computation functionality has been enhanced with the following features:</p> 483<dl> 484 <dt><b>Script intrinsics</b></dt> 485 <dd><p>You can use Renderscript's built-in script intrinsics that implement 486common operations for you such as:</p> 487 <ul> 488 <li>{@link android.renderscript.ScriptIntrinsicBlend Blends}</li> 489 <li>{@link android.renderscript.ScriptIntrinsicBlur Blur}</li> 490 <li>{@link android.renderscript.ScriptIntrinsicColorMatrix Color matrix}</li> 491 <li>{@link android.renderscript.ScriptIntrinsicConvolve3x3 3x3 convolve}</li> 492 <li>{@link android.renderscript.ScriptIntrinsicConvolve5x5 5x5 convolve}</li> 493 <li>{@link android.renderscript.ScriptIntrinsicLUT Per-channel lookup table}</li> 494 <li>{@link android.renderscript.ScriptIntrinsicYuvToRGB Converting an Android YUV buffer to RGB}</li> 495 </ul> 496 <p>To use a script intrinsic, call the static <code>create()</code> method of each instrinsic 497 to create an instance of the script. You then call the available <code>set()</code> 498 methods of each script intrinsic to set any necessary inputs and options. 499 Finally, call the {@link android.renderscript.ScriptC#forEach forEach()}</code> 500 method to execute the script.</p> 501 </dd> 502 503 504<dt><b>Script Groups</b></dt> 505<dd> 506<p>{@link android.renderscript.ScriptGroup}s allow you to chain together related Renderscript 507scripts and execute them with one call.</p> 508 509<p>Use a {@link android.renderscript.ScriptGroup.Builder} to add all of the scripts to the group 510by calling {@link android.renderscript.ScriptGroup.Builder#addKernel addKernel()}. Once you 511add all the scripts, create the connections between the 512scripts by calling {@link android.renderscript.ScriptGroup.Builder#addConnection addConnection()}. 513When you are done adding the connections, call {@link android.renderscript.ScriptGroup.Builder#create create()} 514to create the script group. Before executing the script group, specify the input 515{@link android.renderscript.Allocation} and initial script to run with the 516{@link android.renderscript.ScriptGroup#setInput} method and provide the output 517{@link android.renderscript.Allocation} where the result will be written to and final script to 518run with {@link android.renderscript.ScriptGroup#setOutput setOutput()}. Finally, call 519{@link android.renderscript.ScriptGroup#execute execute()} to run the script group. 520</p> 521</dd> 522 523<dt><b>Filterscript</b></dt> 524<dd> 525<p>Filterscript defines constraints on the existing Renderscript APIs that allow the resulting code to run 526on a wider variety of processors (CPUs, GPUs, and DSPs). To create Filterscript files, create <code>.fs</code> 527files instead of <code>.rs</code> files, and specify <code>#pragma rs_fp_relaxed</code> to 528tell the Renderscript runtime your scripts do not require strict IEEE 754-2008 floating point precision. 529This precision allows flush-to-zero for denorms and round-towards-zero. In addition, your Filterscript 530scripts must not use 32-bit built-in types and must specify a custom root function by using the 531<code>__attribute__((kernel))</code> attribute because Filterscript does not support pointers, which 532the default signature of the <code>root()</code> function defines.</p> 533</dd> 534 535</dl> 536 537<p class="note"><strong>Note:</strong> Although Filterscript support is in the platform, developer 538support will be available in ADT and SDK Tools Release 21.0.1. </p> 539 540 541<p>For a detailed view of all API changes in Android 4.2, see the 542<a href="{@docRoot}sdk/api_diff/17/changes.html">API Differences Report</a>.</p> 543 544 545 546