Home | History | Annotate | Download | only in features
      1 page.title=
      2 page.keywords=PreviewSDK
      3 page.tags=androidn
      4 
      5 @jd:body
      6 
      7 <div id="qv-wrapper">
      8 <div id="qv">
      9 
     10 <h2></h2>
     11 <ol>
     12   <li><a href="#declaring"> Activity 
     13 </a></li>
     14   <li><a href="#pip_button"> Activity </a>
     15 </li>
     16   <li><a href="#handling_ui"> UI</a>
     17 </li>
     18   <li><a href="#continuing_playback">
     19 </a></li>
     20   <li><a href="#single_playback"> Activity
     21 </a></li>
     22   <li><a href="#best"></a></li>
     23 </ol>
     24 
     25 <h2></h2>
     26 <ol>
     27   <li><a href="{@docRoot}preview/features/multi-window.html">
     28 </a></li>
     29 </ol>
     30 
     31 </div>
     32 </div>
     33 
     34 <p> Android N Android TV 
     35 
     36  (PIP)  Activity Activity
     37 
     38 PIP 
     39 </p>
     40 
     41 <p> PIP  PIP 
     42 </p>
     43 
     44 <ul>
     45 <li> PIP 
     46 </li>
     47 <li> PIP 
     48 
     49 </li>
     50 <li>
     51  PIP  Activity
     52 </li>
     53 </ul>
     54 
     55 <p>PIP  240x135 dp
     56  PIP  PIP <b></b> PIP 
     57 
     58 PIP 
     59 
     60  PIP </p>
     61 
     62 <img src="{@docRoot}preview/images/pip-active.png" />
     63 <p class="img-caption"><strong> 1.</strong> 
     64 
     65 </p>
     66 
     67 <p>PIP  Android N  API 
     68  PIP  PIP  Activity Activity  PIP  UI  Activity  PIP 
     69 
     70 
     71 </p>
     72 
     73 <h2 id="declaring"> Activity </h2>
     74 
     75 <p> PIP  PIP
     76 <code>android:supportsPictureInPicture</code> 
     77 <code>android:resizeableActivity</code>  <code>true</code> Activity
     78 
     79  Activity  PIP Activity 
     80 
     81 </p>
     82 
     83 <pre>
     84 &lt;activity android:name="VideoActivity"
     85     android:resizeableActivity="true"
     86     android:supportsPictureInPicture="true"
     87     android:configChanges=
     88         "screenSize|smallestScreenSize|screenLayout|orientation"
     89     ...
     90 </pre>
     91 
     92 <p> Activity  PIP  Activity 
     93  Activity  UI 
     94  PIP UI  Activity  PIP  UI 
     95 
     96 
     97 </p>
     98 
     99 <h2 id="pip_button"> Activity </h2>
    100 
    101  Activity  PIP 
    102 <code>Activity.enterPictureInPictureMode()</code> PIP  PIP 
    103 
    104 </p>
    105 
    106 <pre>
    107 &#64;Override
    108 public void onActionClicked(Action action) {
    109     if (action.getId() == R.id.lb_control_picture_in_picture) {
    110         getActivity().enterPictureInPictureMode();
    111         return;
    112     }
    113     ...
    114 </pre>
    115 
    116 <p> PIP  PIP 
    117 </p>
    118 
    119 <img src="{@docRoot}preview/images/pip-button.png" />
    120 <p class="img-caption"><strong> 1.</strong> 
    121 </p>
    122 
    123 <p>Android N 
    124 <code>PlaybackControlsRow.PictureInPictureAction</code>  PIP  PIP 
    125 </p>
    126 
    127 <h2 id="handling_ui"> UI</h2>
    128 
    129 <p> Activity  PIP Activity 
    130  Activity  PIP  UI  Activity  <code>Activity.onPictureInPictureModeChanged()</code> 
    131 <code>Fragment.onPictureInPictureModeChanged()</code> UI 
    132 
    133 
    134 </p>
    135 
    136 <pre>
    137 &#64;Override
    138 public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
    139     if (isInPictureInPictureMode) {
    140         // Hide the controls in picture-in-picture mode.
    141         ...
    142     } else {
    143         // Restore the playback UI based on the playback status.
    144         ...
    145     }
    146 }
    147 </pre>
    148 
    149 <h2 id="continuing_playback">
    150 </h2>
    151 
    152 <p> Activity  PIP  Activity  Activity  <code>onPause()</code> 
    153  Activity  PIP 
    154 
    155  Activity 
    156 <code>onPause()</code>  PIP
    157 </p>
    158 
    159 <pre>
    160 &#64;Override
    161 public void onPause() {
    162     // If called while in PIP mode, do not pause playback
    163     if (isInPictureInPictureMode()) {
    164         // Continue playback
    165         ...
    166     }
    167     // If paused but not in PIP, pause playback if necessary
    168     ...
    169 }
    170 </pre>
    171 
    172 <p> Activity  PIP  Activity  <code>onResume()</code> 
    173 </p>
    174 
    175 <h2 id="single_playback"> Activity
    176 </h2>
    177 
    178 <p> Activity  PIP 
    179  Activity  Activity
    180 
    181 </p>
    182 
    183 <p> Activity  PIP  Activity  <code>android:launchMode</code>  <code>singleTask</code>
    184 
    185 
    186 </p>
    187 
    188 <pre>
    189 &lt;activity android:name="VideoActivity"
    190     ...
    191     android:supportsPictureInPicture="true"
    192     android:launchMode="singleTask"
    193     ...
    194 </pre>
    195 
    196 <p> Activity  {@link android.app.Activity#onNewIntent
    197 Activity.onNewIntent()}
    198 </p>
    199 
    200 <h2 id="best"></h2>
    201 
    202 <p>PIP  Activity Activity  PIP <a href="#handling_ui"> UI</a>  Activity  PIP  UI 
    203 
    204 
    205 </p>
    206 
    207 <p> PIP  PIP 
    208 
    209 </p>
    210 
    211 <p> Activity  PIP  PIP 
    212 <code>MediaSession.setMediaButtonReceiver()</code>
    213 </p>
    214