Home | History | Annotate | Download | only in new
      1 page.title=What's New
      2 page.image=images/cards/samples-new_2x.png
      3 
      4 @jd:body
      5 
      6 <p>The following code samples were recently published. You can
      7 download them in the Android SDK Manager under the <b>SDK Samples</b> component
      8 for API 21.</p>
      9 
     10 <p class="note">
     11   <strong>Note:</strong> The downloadable projects are designed
     12    for use with Gradle and Android Studio.
     13 </p>
     14 
     15 <!-- NOTE TO EDITORS: add most recent samples first -->
     16 
     17 <h3 id="MediaBrowserService"><a href="/samples/MediaBrowserService/index.html">Media Browser Service</a></h3>
     18 
     19 <p>
     20 This sample is a simple audio media app that exposes its media
     21 library and provides metadata and playback controls through the new
     22 MediaBrowserService and MediaSession APIs from API 21.
     23 The sample is compatible with Android Auto and also provides a basic UI
     24 when not connected to a car.
     25 </p>
     26 
     27 <p class="note">
     28   <strong>Note:</strong> This sample is compatible with <a
     29   href="http://android.com/auto">Android Auto</a>.
     30 </p>
     31 
     32 
     33 <h3 id="MessagingService"><a href="/samples/MessagingService/index.html">Messaging Service</a></h3>
     34 
     35 <p>
     36 This sample shows a simple service that sends notifications using
     37 NotificationCompat. In addition to sending a notification, it also extends
     38 the notification with a CarExtender to make it compatible with Android Auto.
     39 Each unread conversation from a user is sent as a distinct notification.
     40 </p>
     41 
     42 <p class="note">
     43   <strong>Note:</strong> This sample is compatible with <a
     44   href="http://android.com/auto">Android Auto</a>.
     45 </p>
     46 
     47 
     48 <h3 id="SpeedTracker"><a href="/samples/SpeedTracker/index.html">Speed Tracker (Wear)</a></h3>
     49 
     50 <p>
     51 This sample uses the FusedLocation APIs of Google Play Services on Android Wear 
     52 devices that have a hardware GPS built in. In those cases, this sample provides
     53 a simple screen that shows the current speed of the wearable device. User can
     54 set a speed limit and if the speed approaches that limit, it changes the color
     55 to yellow and if it exceeds the limit, it turns red. User can also enable
     56 recording of coordinates and when it pairs back with the phone, this data
     57 is synced with the phone component of the app and user can see a track
     58 made of those coordinates on a map on the phone.
     59 </p>
     60 
     61 
     62 <h3 id="AppRestrictionSchema"><a href="/samples/AppRestrictionSchema/index.html">AppRestrictionSchema</a></h3>
     63 
     64 <p>
     65 This sample shows how to use app restrictions. This application has one boolean
     66 restriction with a key "can_say_hello" that defines whether the only feature of this
     67 app (press the button to show "Hello" message) is enabled or disabled. Use
     68 AppRestrictionEnforcer sample to toggle the restriction.
     69 </p>
     70 
     71 
     72 <h3 id="AppRestrictionEnforcer"><a href="/samples/AppRestrictionEnforcer/index.html">AppRestrictionEnforcer</a></h3>
     73 
     74 <p>
     75 This sample demonstrates how to set restrictions to other apps as a profile owner.
     76 Use AppRestrictionSchema sample as a app with available restrictions.
     77 </p>
     78 
     79 
     80 <h3 id="DocumentCentricRelinquishIdentity"><a href="/samples/DocumentCentricRelinquishIdentity/index.html">DocumentCentricRelinquishIdentity</a></h3>
     81 
     82 <p>
     83 This sample shows how to relinquish identity to activities above it in the task stack.
     84 </p>
     85 
     86 
     87 <h3 id="DocumentCentricApps"><a href="/samples/DocumentCentricApps/index.html">DocumentCentricApps</a></h3>
     88 
     89 <p>
     90 This sample shows the basic usage of the new "Document Centric Apps" API.
     91 It let's you create new documents in the system overview menu and persists its
     92 state through reboots. If "Task per document" is checked a new task will be
     93 created for every new document in the overview menu.
     94 </p>
     95 
     96 
     97 <h3 id="HdrViewfinder"><a href="/samples/HdrViewfinder/index.html">HdrViewfinder</a></h3>
     98 
     99 <p>
    100 This demo implements a real-time high-dynamic-range camera viewfinder, by alternating
    101 the sensor's exposure time between two exposure values on even and odd frames, and then
    102 compositing together the latest two frames whenever a new frame is captured.
    103 </p>
    104 
    105 
    106 <h3 id="Interpolator"><a href="/samples/Interpolator/index.html">Interpolator</a></h3>
    107 
    108 <p>
    109 This sample demonstrates the use of animation interpolators and path animations for
    110 Material Design. It shows how an ObjectAnimator is used to animate two properties of a
    111 view (scale X and Y) along a path.
    112 </p>
    113 
    114 
    115 <h3 id="DrawableTinting"><a href="/samples/DrawableTinting/index.html">DrawableTinting</a></h3>
    116 
    117 <p>Sample that shows applying tinting and color filters to Drawables both programmatically
    118 and as Drawable resources in XML.</p>
    119 <p>Tinting is set on a nine-patch drawable through the "tint" and "tintMode" parameters.
    120 A color state list is referenced as the tint color, which defines colors for different
    121 states of a View (for example disabled/enabled, focused, pressed or selected).</p>
    122 <p>Programmatically, tinting is applied to a Drawable through its "setColorFilter" method,
    123 with a reference to a color and a PorterDuff blend mode. The color and blend mode can be
    124 changed from the UI to see the effect of different options.</p>
    125 
    126 
    127 <h3 id="LNotifications"><a href="/samples/LNotifications/index.html">LNotifications</a></h3>
    128 
    129 <p>
    130 This sample demonstrates how new features for notifications introduced in Android 5.0
    131 are used such as Heads-Up notifications, visibility, people, category and priority
    132 metadata. </p>
    133 
    134 
    135 <h3 id="CardView"><a href="/samples/CardView/index.html">CardView</a></h3>
    136 
    137 <p>
    138 This sample demonstrates how to use the CardView UI widget introduced in Android 5.0, using the support library for backward compatibility.
    139 </p>
    140 
    141 
    142 <h3 id="RecyclerView"><a href="/samples/RecyclerView/index.html">RecyclerView</a></h3>
    143 
    144 <p>
    145 Demonstration of using RecyclerView with a LayoutManager to create a vertical ListView.
    146 </p>
    147 
    148 
    149 <h3 id="RevealEffectBasic"><a href="/samples/RevealEffectBasic/index.html">RevealEffectBasic</a></h3>
    150 
    151 <p>
    152 A sample demonstrating how to perform a reveal effect for UI elements within the Material Design framework.
    153 </p>
    154 
    155 
    156 <h3 id="FloatingActionButtonBasic"><a href="/samples/FloatingActionButtonBasic/index.html">FloatingActionButtonBasic</a></h3>
    157 
    158 <p>
    159 This sample shows the two sizes of Floating Action Buttons and how to interact with
    160 them.
    161 </p>
    162 
    163 
    164 <!--
    165 <h3 id="">SampleName</h3>
    166 
    167 <div class="figure" style="width:220px">
    168   <img src="" srcset="@2x.png 2x" alt="" height="375" />
    169   <p class="img-caption">
    170     <strong>Figure n.</strong> Single sentence summarizing the figure.
    171   </p>
    172 </div>
    173 
    174 <p>
    175 **description**
    176 </p>
    177 -->
    178 
    179 <h3 id="JobSchedulerSample"><a href="/samples/JobScheduler/index.html">JobScheduler</a></h3>
    180 
    181 <p>
    182 This sample app allows the user to schedule jobs through the UI, and shows
    183 visual cues when the jobs are executed.
    184 </p>
    185 
    186 
    187 <h3 id="AndroidTVLeanbackSample"><a href="https://github.com/googlesamples/androidtv-leanback">AndroidTVLeanbackSample</a></h3>
    188 <!--
    189 <div class="figure" style="width:220px">
    190   <img src="" srcset="@2x.png 2x" alt="" height="375" />
    191   <p class="img-caption">
    192     <strong>Figure n.</strong> Single sentence summarizing the figure.
    193   </p>
    194 </div>
    195 -->
    196 
    197 <p>
    198 This sample demonstrates use of the Android TV Leanback Support Library.
    199 </p>
    200 
    201 <h3 id="Visual-Game-Controller"><a href="https://github.com/googlesamples/androidtv-VisualGameController">Visual-Game-Controller</a></h3>
    202 <!--
    203 <div class="figure" style="width:220px">
    204   <img src="" srcset="@2x.png 2x" alt="" height="375" />
    205   <p class="img-caption">
    206     <strong>Figure n.</strong> Single sentence summarizing the figure.
    207   </p>
    208 </div>
    209 -->
    210 
    211 <p>
    212 This sample displays events received from a game controller shown on the screen.
    213 </p>
    214 
    215 
    216 <h3 id="GameControllerSample"><a href="https://github.com/googlesamples/androidtv-GameController/">GameControllerSample</a></h3>
    217 <!--
    218 <div class="figure" style="width:220px">
    219   <img src="" srcset="@2x.png 2x" alt="" height="375" />
    220   <p class="img-caption">
    221     <strong>Figure n.</strong> Single sentence summarizing the figure.
    222   </p>
    223 </div>
    224 -->
    225 
    226 <p>
    227 This sample implements a multi-player game, demonstrating game controller input
    228 handling.
    229 </p>
    230 
    231 
    232 <h3 id="ClippingBasic"><a href="/samples/ClippingBasic/index.html">ClippingBasic</a></h3>
    233 <!--
    234 <div class="figure" style="width:220px">
    235   <img src="" srcset="@2x.png 2x" alt="" height="375" />
    236   <p class="img-caption">
    237     <strong>Figure n.</strong> Single sentence summarizing the figure.
    238   </p>
    239 </div>
    240 -->
    241 
    242 <p>
    243 This sample demonstrates clipping on a {@link android.view.View}.
    244 </p>
    245 
    246 <div class="figure" style="width:220px">
    247   <img src="{@docRoot}samples/images/JobSchedulerSample.png"
    248       srcset="{@docRoot}samples/images/JobSchedulerSample@2x.png 2x"
    249       alt="" height="375" />
    250   <p class="img-caption">
    251     <strong>Figure 1.</strong> The JobSchedulerSample sample app.
    252   </p>
    253 </div>
    254 
    255 
    256 <h3 id="ElevationDrag"><a href="/samples/ElevationDrag/index.html">ElevationDrag</a></h3>
    257 <!--
    258 <div class="figure" style="width:220px">
    259   <img src="" srcset="@2x.png 2x" alt="" height="375" />
    260   <p class="img-caption">
    261     <strong>Figure n.</strong> Single sentence summarizing the figure.
    262   </p>
    263 </div>
    264 -->
    265 
    266 <p>This sample demonstrates a drag and drop action on different shapes.
    267 Elevation and z-translation are used to render the shadows. The views are
    268 clipped using different outlines.</p>
    269 
    270 
    271 <h3 id="ElevationBasic"><a href="/samples/ElevationBasic/index.html">ElevationBasic</a></h3>
    272 <!--
    273 <div class="figure" style="width:220px">
    274 <img src="" srcset="@2x.png 2x" alt="" height="375" />
    275     <p class="img-caption">
    276     <strong>Figure n.</strong> Single sentence summarizing the figure.
    277   </p>
    278 </div>
    279 -->
    280 
    281 <p>
    282 This sample demonstrates two alternative ways to move a view in the z-axis:</p>
    283 
    284 <ul>
    285   <li>With a fixed elevation, using XML.</li>
    286   <li>Raising the elevation when the user taps on it, using
    287       <code>setTranslationZ()</code>.</li>
    288 </ul>
    289 
    290 
    291 <h3 id="ActivitySceneTransitionBasic"><a href="/samples/ActivitySceneTransitionBasic/index.html">ActivitySceneTransitionBasic</a></h3>
    292 <div class="figure" style="width:220px">
    293   <img src="{@docRoot}samples/images/ActivitySceneTransitionBasic.png"
    294       srcset="{@docRoot}samples/images/ActivitySceneTransitionBasic@2x.png 2x"
    295       alt="" height="375" />
    296   <p class="img-caption">
    297     <strong>Figure 2.</strong> The ActivitySceneTransitionBasic sample app.
    298   </p>
    299   </div>
    300 
    301 <p> This sample demonstrates how to the use {@link android.app.Activity} scene
    302 transitions when transitioning from one activity to another. Uses a combination
    303 of <code>moveImage</code> and <code>changeBounds</code> to nicely transition
    304 from a grid of images to an activity with a large image and detail text. </p>
    305 
    306 
    307 <h3 id="Camera2Video"><a href="/samples/Camera2Video/index.html">Camera2Video</a></h3>
    308 <!--
    309 <div class="figure" style="width:220px">
    310 <img src="" srcset="@2x.png 2x" alt="" height="375" />
    311     <p class="img-caption">
    312     <strong>Figure n.</strong> Single sentence summarizing the figure.
    313   </p>
    314 </div>
    315 -->
    316 
    317 <p>This sample demonstrates how to record video using the Camera2 API.</p>
    318 
    319 
    320 <h3 id="Camera2Basic"><a href="/samples/Camera2Basic/index.html">Camera2Basic</a></h3>
    321 
    322 <!--
    323 <div class="figure" style="width:220px">
    324   <img src="" srcset="@2x.png 2x" alt="" height="375" />
    325   <p class="img-caption">
    326     <strong>Figure n.</strong> Single sentence summarizing the figure.
    327   </p>
    328 </div>
    329 -->
    330 
    331 <p>This sample demonstrates the basic use of the Camera2 API. The sample code
    332 demonstrates how you can display camera preview and take pictures.</p>
    333 
    334 
    335 <h3 id="BasicManagedProfile"><a href="/samples/BasicManagedProfile/index.html">BasicManagedProfile</a></h3>
    336 <div class="figure" style="width:220px">
    337   <img src="{@docRoot}samples/images/BasicManagedProfile.png"
    338      srcset="{@docRoot}samples/images/BasicManagedProfile@2x.png 2x"
    339      alt="" height="375" />
    340   <p class="img-caption">
    341     <strong>Figure 3.</strong> The BasicManagedProfile sample app.
    342   </p>
    343 </div>
    344 
    345 <p>This sample demonstrates how to create a managed profile. You can also:</p>
    346 <ul>
    347   <li>Enable or disable other apps, and set restrictions on them.</li>
    348   <li>Configure intents to be forwarded between the primary account and the
    349    managed profile.</li>
    350   <li>Wipe all the data associated with the managed profile.</li>
    351 </ul>
    352 
    353 <p class="note"><strong>Note:</strong> There can be only one managed profile on
    354   a device at a time.</p>
    355 
    356