Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fe42219 authored by Joe Fernandez's avatar Joe Fernandez
Browse files

docs: Add more information for getting started with TV app

- required manifest entries
- more information on permissions that imply hardware features

Change-Id: I55454ba8725185094bef35b9be653d50b58c8137
parent bf78adb2
Loading
Loading
Loading
Loading
+60 −17
Original line number Original line Diff line number Diff line
@@ -85,27 +85,27 @@ if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION)
  </tr>
  </tr>
  <tr>
  <tr>
    <td>Touchscreen</td>
    <td>Touchscreen</td>
    <td>android.hardware.touchscreen</td>
    <td>{@code android.hardware.touchscreen}</td>
  </tr>
  </tr>
  <tr>
  <tr>
    <td>Telephony</td>
    <td>Telephony</td>
    <td>android.hardware.telephony</td>
    <td>{@code android.hardware.telephony}</td>
  </tr>
  </tr>
  <tr>
  <tr>
    <td>Camera</td>
    <td>Camera</td>
    <td>android.hardware.camera</td>
    <td>{@code android.hardware.camera}</td>
  </tr>
  </tr>
  <tr>
  <tr>
    <td>Near Field Communications (NFC)</td>
    <td>Near Field Communications (NFC)</td>
    <td>android.hardware.nfc</td>
    <td>{@code android.hardware.nfc}</td>
  </tr>
  </tr>
  <tr>
  <tr>
    <td>GPS</td>
    <td>GPS</td>
    <td>android.hardware.location.gps</td>
    <td>{@code android.hardware.location.gps}</td>
  </tr>
  </tr>
  <tr>
  <tr>
    <td>Microphone</td>
    <td>Microphone</td>
    <td>android.hardware.microphone</td>
    <td>{@code android.hardware.microphone}</td>
  </tr>
  </tr>
</table>
</table>


@@ -142,20 +142,17 @@ if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION)
        android:required="false"/&gt;
        android:required="false"/&gt;
</pre>
</pre>


<p class="caution">
<p>
  <strong>Caution:</strong> Declaring an unavailable hardware feature as required by setting its
  All apps intended for use on TV devices must declare that the touch screen feature is not required
  value to {@code true} in your app manifest prevents your app from being installed on TV
  as described in <a href="{@docRoot}training/tv/start/start.html#no-touchscreen">Get Started with
  devices or appearing in the Android TV home screen launcher.
  TV Apps</a>. If your app normally uses one or more of the features listed above, change the
  {@code android:required} attribute setting to {@code false} for those features in your manifest.
</p>
</p>


<p class="caution">
<p class="caution">
  <strong>Caution:</strong> Some <a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">{@code uses-permission}</a> manifest declarations <em>imply hardware use</em>, which can also
  <strong>Caution:</strong> Declaring a hardware feature as required by setting its
  prevent your app from being installed and used on TV devices. For example, requesting the
  value to {@code true}  prevents your app from being installed on TV
  {@link android.Manifest.permission#RECORD_AUDIO} permission in your app implies the
  devices or appearing in the Android TV home screen launcher.
  {@code android.hardware.microphone} hardware feature requirement. In which case, you must declare
  the microphone feature as not required ({@code android:required="false"}) in your app manifest.
  For a list of permission requests that imply a hardware feature requirement, see <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions-features">
  {@code uses-feature}</a> guide.
</p>
</p>


<p>
<p>
@@ -172,6 +169,52 @@ if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION)
</p>
</p>




<h3 id="hardware-permissions">Declaring permissions that imply hardware features</h3>

<p>
  Some <a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">{@code uses-permission}</a>
  manifest declarations <em>imply hardware features</em>. This behavior means that requesting some
  permissions in your app manifest can exclude your app from from being installed and used on TV
  devices. The following commonly requested permissions create an implicit hardware feature
  requirement:
</p>

<table>
  <tr>
    <th>Permission</th>
    <th>Implied hardware feature</th>
  </tr>
  <tr>
    <td>{@link android.Manifest.permission#RECORD_AUDIO}</td>
    <td>{@code android.hardware.microphone}</td>
  </tr>
  <tr>
    <td>{@link android.Manifest.permission#CAMERA}</td>
    <td>{@code android.hardware.camera} <em>and</em> <br>
      {@code android.hardware.camera.autofocus}</td>
  </tr>
  <tr>
    <td>{@link android.Manifest.permission#ACCESS_COARSE_LOCATION}</td>
    <td>{@code android.hardware.location} <em>and</em> <br>
      {@code android.hardware.location.network}</td>
  </tr>
  <tr>
    <td>{@link android.Manifest.permission#ACCESS_FINE_LOCATION}</td>
    <td>{@code android.hardware.location} <em>and</em> <br>
      {@code android.hardware.location.gps}</td>
  </tr>
</table>

<p>
  For a complete list of permission requests that imply a hardware feature requirement, see
  <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions-features">{@code
  uses-feature}</a> guide. If your app requests one of the features listed above, include a
  <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code uses-feature}</a>
  declaration in your manifest for the implied hardware feature that indicates it is not
  required ({@code android:required="false"}).
</p>


<h3 id="check-features">Checking for hardware features</h2>
<h3 id="check-features">Checking for hardware features</h2>


<p>
<p>
+40 −12
Original line number Original line Diff line number Diff line
@@ -11,6 +11,7 @@ startpage=true
  <h2>This lesson teaches you how to</h2>
  <h2>This lesson teaches you how to</h2>
  <ol>
  <ol>
    <li><a href="#dev-project">Setup a TV Project</a></li>
    <li><a href="#dev-project">Setup a TV Project</a></li>
    <li><a href="#tv-libraries">Add TV Support Libraries</a></li>
    <li><a href="#build-it">Build TV Apps</a></li>
    <li><a href="#build-it">Build TV Apps</a></li>
    <li><a href="#run">Run TV Apps</a></li>
    <li><a href="#run">Run TV Apps</a></li>
  </ol>
  </ol>
@@ -86,17 +87,10 @@ startpage=true


<p>An application intended to run on TV devices must declare a launcher activity for TV
<p>An application intended to run on TV devices must declare a launcher activity for TV
  in its manifest using a {@link android.content.Intent#CATEGORY_LEANBACK_LAUNCHER} intent filter.
  in its manifest using a {@link android.content.Intent#CATEGORY_LEANBACK_LAUNCHER} intent filter.
  This filter identifies your app as being enabled for TV, allowing it to be considered a TV app
  This filter identifies your app as being enabled for TV, and is required for your app to be
  in Google Play. Declaring this intent also identifies which activity
  considered a TV app in Google Play. Declaring this intent also identifies which activity
  in your app to launch when a user selects its icon on the TV home screen.</p>
  in your app to launch when a user selects its icon on the TV home screen.</p>


<p class="caution">
  <strong>Caution:</strong> If you do not include the {@link android.content.Intent#CATEGORY_LEANBACK_LAUNCHER} intent filter in
  your app, it is not visible to users running the Google Play store on TV devices. Also, if your
  app does not have this filter when you load it onto a TV device using developer tools, the app
  does not appear in the TV user interface.
</p>

<p>The following code snippet shows how to include this intent filter in your manifest:</p>
<p>The following code snippet shows how to include this intent filter in your manifest:</p>


<pre>
<pre>
@@ -132,6 +126,14 @@ startpage=true
  launch on a TV device.
  launch on a TV device.
</p>
</p>


<p class="caution">
  <strong>Caution:</strong> If you do not include the
  {@link android.content.Intent#CATEGORY_LEANBACK_LAUNCHER} intent filter in
  your app, it is not visible to users running the Google Play store on TV devices. Also, if your
  app does not have this filter when you load it onto a TV device using developer tools, the app
  does not appear in the TV user interface.
</p>

<p>
<p>
  If you are modifying an existing app for use on TV, your app should not use the same
  If you are modifying an existing app for use on TV, your app should not use the same
  activity layout for TV that it does for phones and tablets. The user interface of your TV app (or
  activity layout for TV that it does for phones and tablets. The user interface of your TV app (or
@@ -142,6 +144,31 @@ startpage=true
  "{@docRoot}training/tv/start/layouts.html">Building TV Layouts</a>.
  "{@docRoot}training/tv/start/layouts.html">Building TV Layouts</a>.
</p>
</p>



<h3 id="no-touchscreen">Declare touchscreen not required</h3>

<p>
  Applications that are intended to run on TV devices do not rely on touch screens for input. In
  order to make this clear, the manifest of your TV app must declare that a the {@code
  android.hardware.touchscreen} feature is not required. This setting identifies your app as being
  able to work on a TV device, and is required for your app to be considered a TV app in Google
  Play. The following code example shows how to include this manifest declaration:
</p>

<pre>
&lt;manifest&gt;
    <strong>&lt;uses-feature android:name="android.hardware.touchscreen"
              android:required="false" /&gt;</strong>
    ...
&lt;/manifest&gt;
</pre>

<p class="caution">
  <strong>Caution:</strong> You must declare that a touch screen is not required in your app
  manifest, as shown this example code, or your app cannot appear in the Google Play store on TV
  devices.
</p>

<h3 id="banner">Provide a home screen banner</h3>
<h3 id="banner">Provide a home screen banner</h3>


<p>
<p>
@@ -154,6 +181,7 @@ startpage=true
&lt;application
&lt;application
    ...
    ...
    android:banner="&#64;drawable/banner" &gt;
    android:banner="&#64;drawable/banner" &gt;

    ...
    ...
&lt;/application&gt;
&lt;/application&gt;
</pre>
</pre>
@@ -171,7 +199,7 @@ startpage=true
  design guide.
  design guide.
</p>
</p>


<h3 id="tv-libraries">Add TV support libraries</h3>
<h2 id="tv-libraries">Add TV Support Libraries</h3>


<p>
<p>
  The Android SDK includes support libraries that are intended for use with TV apps. These
  The Android SDK includes support libraries that are intended for use with TV apps. These