Home | History | Annotate | Download | only in start
      1 page.title= TV 
      2 page.tags=tv
      3 trainingnavtop=true
      4 
      5 @jd:body
      6 
      7 <div id="tb-wrapper">
      8 <div id="tb">
      9   <h2></h2>
     10   <ol>
     11     <li><a href="#runtime-check">TV </a>
     12     <li><a href="#handle-features"></a></li>
     13     <li><a href="#controllers"> </a>
     14     </li>
     15   </ol>
     16 </div>
     17 </div>
     18 
     19 <p>
     20   TV  Android TV GPS  Android  TV 2  TV TV  TV 
     21 </p>
     22 
     23 <p>
     24   TV  TV 
     25 </p>
     26 
     27 
     28 <h2 id="runtime-check">TV </h2>
     29 
     30 <p>
     31   TV {@link android.content.Intent} 
     32 </p>
     33 
     34 <p>
     35   TV {@link android.app.UiModeManager#getCurrentModeType UiModeManager.getCurrentModeType()}  TV TV 
     36 </p>
     37 
     38 <pre>
     39 public static final String TAG = "DeviceTypeRuntimeCheck";
     40 
     41 UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
     42 if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
     43     Log.d(TAG, "Running on a TV Device")
     44 } else {
     45     Log.d(TAG, "Running on a non-TV Device")
     46 }
     47 </pre>
     48 
     49 
     50 <h2 id="handle-features"></h2>
     51 
     52 <p>
     53    TV 
     54 </p>
     55 
     56 
     57 <h3 id="unsupported-features"> TV </h3>
     58 
     59 <p>
     60   TV  Android Android  TV 
     61 </p>
     62 
     63 <table>
     64   <tr>
     65     <th></th>
     66     <th>Android  Feature Descriptor</th>
     67   </tr>
     68   <tr>
     69     <td></td>
     70     <td>{@code android.hardware.touchscreen}</td>
     71   </tr>
     72   <tr>
     73     <td></td>
     74     <td>{@code android.hardware.telephony}</td>
     75   </tr>
     76   <tr>
     77     <td></td>
     78     <td>{@code android.hardware.camera}</td>
     79   </tr>
     80   <tr>
     81     <td>NFC</td>
     82     <td>{@code android.hardware.nfc}</td>
     83   </tr>
     84   <tr>
     85     <td>GPS</td>
     86     <td>{@code android.hardware.location.gps}</td>
     87   </tr>
     88   <tr>
     89     <td></td>
     90     <td>{@code android.hardware.microphone}</td>
     91   </tr>
     92 </table>
     93 
     94 
     95 <h3 id="declare-hardware-requirements">TV </h3>
     96 
     97 <p>
     98   Android TV TV 
     99 </p>
    100 
    101 <p>
    102    TV TV  TV TV 
    103 </p>
    104 
    105 <pre>
    106 &lt;uses-feature android:name="android.hardware.touchscreen"
    107         android:required="false"/&gt;
    108 &lt;uses-feature android:name="android.hardware.telephony"
    109         android:required="false"/&gt;
    110 &lt;uses-feature android:name="android.hardware.camera"
    111         android:required="false"/&gt;
    112 &lt;uses-feature android:name="android.hardware.nfc"
    113         android:required="false"/&gt;
    114 &lt;uses-feature android:name="android.hardware.gps"
    115         android:required="false"/&gt;
    116 &lt;uses-feature android:name="android.hardware.microphone"
    117         android:required="false"/&gt;
    118 </pre>
    119 
    120 <p>
    121   TV <a href="{@docRoot}training/tv/start/start.html#no-touchscreen">TV </a> 1  {@code android:required}  {@code false} 
    122 </p>
    123 
    124 <p class="caution">
    125   <strong>:</strong> {@code true} TV Android  TV   
    126 </p>
    127 
    128 <p>
    129   
    130 </p>
    131 
    132 <p>
    133   <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code uses-feature}</a>
    134 </p>
    135 
    136 
    137 <h3 id="hardware-permissions"></h3>
    138 
    139 <p>
    140   <a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">{@code uses-permission}</a> <em></em> TV 
    141 </p>
    142 
    143 <table>
    144   <tr>
    145     <th></th>
    146     <th></th>
    147   </tr>
    148   <tr>
    149     <td>{@link android.Manifest.permission#RECORD_AUDIO}</td>
    150     <td>{@code android.hardware.microphone}</td>
    151   </tr>
    152   <tr>
    153     <td>{@link android.Manifest.permission#CAMERA}</td>
    154     <td>{@code android.hardware.camera} <em></em> <br/> {@code android.hardware.camera.autofocus}</td>
    155   </tr>
    156   <tr>
    157     <td>{@link android.Manifest.permission#ACCESS_COARSE_LOCATION}</td>
    158     <td>{@code android.hardware.location} <em></em> <br/> {@code android.hardware.location.network}</td>
    159   </tr>
    160   <tr>
    161     <td>{@link android.Manifest.permission#ACCESS_FINE_LOCATION}</td>
    162     <td>{@code android.hardware.location} <em></em> <br/> {@code android.hardware.location.gps}</td>
    163   </tr>
    164 </table>
    165 
    166 <p>
    167   <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions-features">{@code uses-feature}</a> <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code uses-feature}</a> {@code android:required="false"}
    168 </p>
    169 
    170 
    171 <h3 id="check-features"></h2>
    172 
    173 <p>
    174   Android {@link android.content.pm.PackageManager#hasSystemFeature(String)} 
    175 </p>
    176 
    177 <p></p>
    178 
    179 <pre>
    180 // Check if the telephony hardware feature is available.
    181 if (getPackageManager().hasSystemFeature("android.hardware.telephony")) {
    182     Log.d("HardwareFeatureTest", "Device can make phone calls");
    183 }
    184 
    185 // Check if android.hardware.touchscreen feature is available.
    186 if (getPackageManager().hasSystemFeature("android.hardware.touchscreen")) {
    187     Log.d("HardwareFeatureTest", "Device has a touch screen.");
    188 }
    189 </pre>
    190 
    191 
    192 <h4 id="no-touchscreen"></h4>
    193 
    194 <p>
    195   TV Android  TV  10  TV 
    196 </p>
    197 
    198 <p>
    199   TV TV  TV <a href="{@docRoot}training/tv/start/navigation.html">TV </a>
    200 </p>
    201 
    202 
    203 <h4 id="no-camera"></h4>
    204 
    205 <p>
    206   TV TV TV 
    207 </p>
    208 
    209 <pre>
    210 &lt;uses-feature android:name="android.hardware.camera" android:required="false" /&gt;
    211 </pre>
    212 
    213 <p>
    214   
    215 </p>
    216 
    217 <pre>
    218 // Check if the camera hardware feature is available.
    219 if (getPackageManager().hasSystemFeature("android.hardware.camera")) {
    220     Log.d("Camera test", "Camera available!");
    221 } else {
    222     Log.d("Camera test", "No camera available. View and edit features only.");
    223 }
    224 </pre>
    225 
    226 
    227 <h4 id="no-gps">GPS</h4>
    228 
    229 <p>
    230   TV GPSTV  
    231 </p>
    232 
    233 <pre>
    234 // Request a static location from the location manager
    235 LocationManager locationManager = (LocationManager) this.getSystemService(
    236         Context.LOCATION_SERVICE);
    237 Location location = locationManager.getLastKnownLocation("static");
    238 
    239 // Attempt to get postal or zip code from the static location object
    240 Geocoder geocoder = new Geocoder(this);
    241 Address address = null;
    242 try {
    243   address = geocoder.getFromLocation(location.getLatitude(),
    244           location.getLongitude(), 1).get(0);
    245   Log.d("Zip code", address.getPostalCode());
    246 
    247 } catch (IOException e) {
    248   Log.e(TAG, "Geocoder error", e);
    249 }
    250 </pre>
    251 
    252 
    253 <h2 id="controllers"></h2>
    254 
    255 <p>
    256   TV 2 
    257 </p>
    258 
    259 
    260 <h3 id="d-pad-minimum"></h3>
    261 
    262 <p>
    263   TV  [][][]  TV TV <a href="{@docRoot}training/tv/start/navigation.html">TV </a>
    264 </p>
    265 
    266 
    267 <h3 id="controller-disconnects"></h3>
    268 
    269 <p>
    270   TV  Bluetooth   TV 
    271 </p>
    272 
    273 <ul>
    274   <li> TV 
    275   </li>
    276   <li>
    277   </li>
    278   <li>
    279   </li>
    280 </ul>
    281 
    282 <p>
    283    TV  
    284 </p>
    285 
    286 <pre>
    287 &lt;activity
    288   android:name="com.example.android.TvActivity"
    289   android:label="&#64;string/app_name"
    290   <strong>android:configChanges="keyboard|keyboardHidden|navigation"</strong>
    291   android:theme="&#64;style/Theme.Leanback"&gt;
    292 
    293   &lt;intent-filter&gt;
    294     &lt;action android:name="android.intent.action.MAIN" /&gt;
    295     &lt;category android:name="android.intent.category.LEANBACK_LAUNCHER" /&gt;
    296   &lt;/intent-filter&gt;
    297   ...
    298 &lt;/activity&gt;
    299 </pre>
    300 
    301 <p>
    302   Android  
    303 </p>
    304 
    305 
    306 <h3 id="d-pad-variants"></h3>
    307 
    308 <p>
    309   TV  TV TV 
    310 </p>
    311 
    312 <p>
    313   <a href="{@docRoot}training/game-controllers/controller-input.html#dpad"></a>
    314 </p>
    315