Home | History | Annotate | Download | only in start
      1 page.title=Getting Started with Auto
      2 page.tags="auto", "car", "automotive"
      3 page.article=true
      4 page.image=auto/images/assets/icons/auto_app_in_simulator.png
      5 
      6 @jd:body
      7 
      8 <div id="tb-wrapper">
      9 <div id="tb">
     10   <h2>Dependencies and Prerequisites</h2>
     11   <ul>
     12     <li>Android 5.0 (API level 21) or higher</li>
     13   </ul>
     14 
     15   <h2>This class teaches you how to</h2>
     16   <ol>
     17     <li><a href="#dev-project">Set Up an Auto Project</a></li>
     18     <li><a href="#build-it">Build Auto Apps</a></li>
     19   </ol>
     20 
     21  <h2>You should also read</h2>
     22  <ul>
     23    <li><a href="{@docRoot}design/auto/index.html">Designing for Auto</a></li>
     24    <li><a href="{@docRoot}distribute/googleplay/auto.html">Distribute to Android Auto</a></li>
     25    <li><a href="{@docRoot}training/auto/audio/index.html">Providing Audio Playback with Auto</a></li>
     26    <li><a href="{@docRoot}training/auto/messaging/index.html">Providing Messaging for Auto</a></li>
     27  </ul>
     28 </div>
     29 </div>
     30 
     31 <p>Android Auto extends the Android platform into the car. When users connect
     32 their handheld devices running Android 5.0 or higher to a compatible vehicle,
     33 the Auto user interface provides a car-optimized Android experience on the
     34 vehicle's screen. Users interact with compatible apps and services through
     35 voice actions and the vehicle's input controls (like a touchscreen or dashboard
     36 buttons).</p>
     37 
     38 <p>Auto currently supports two types of apps:</p>
     39 
     40 <ul>
     41 <li><em>Audio apps</em> that allow users to browse and play music and spoken
     42 audio content in the car.</li>
     43 <li><em>Messaging apps</em> that receive incoming notifications, read messages
     44   aloud via text-to-speech, and send replies via voice input in the car.</li>
     45 </ul>
     46 
     47 <p>You can enable your existing audio and messaging apps developed for
     48 phones and tablets to work in the car, without having to worry about
     49 vehicle-specific hardware differences. To enable your app for Auto, your
     50 app must target Android 5.0 (API level 21) or higher. Your apps manifest must
     51 also declare the car capabilities that it uses, such as audio playback or
     52 messaging services. </p>
     53 
     54 <p>This lesson describes how to start building apps for Auto, including
     55 setting up your development environment and meeting the the minimum requirements
     56 to enable an app to communicate with Auto.</p>
     57 
     58 <h2 id="dev-project">Set Up an Auto Project</h2>
     59 <p>This section describes how to create a new app or modify an existing app to
     60 communicate with Auto.</p>
     61 
     62 <h3 id="prerequisites">Prerequisites</h3>
     63 <p>Before you begin building apps for Auto, you must:</p>
     64 
     65 <ul>
     66 <li><strong><a href="{@docRoot}studio/projects/create-project.html">Create or
     67 update your app project</a></strong> - Android 5.0 (API level 21) provides new
     68 APIs for implementing audio playback and messaging that is compatible with Auto.
     69 To access the new APIs, create a project or modify an existing project to target
     70 Android 5.0 (API level 21) or higher. This means you must set the manifest
     71 <a href="{@docRoot}topics/manifest/uses-sdk-element.html">{@code targetSdkVersion}</a>
     72 to 21 or higher.
     73 </li>
     74 <li><strong><a href="{@docRoot}tools/support-library/setup.html">Install the
     75 support library</a></strong> - If you are building messaging apps for Auto, you
     76 need the {@link android.support.v4.app.NotificationCompat.CarExtender} class
     77 contained in the
     78 <a href="{@docRoot}tools/support-library/features.html#v4">v4 support library</a>.
     79 This class allows you to create notifications that are compatible with Auto
     80 devices.</li>
     81 </ul>
     82 
     83 <h3 id="auto-metadata">Declare Auto capabilities</h3>
     84 <p>The Auto features that your app can access are controlled
     85 by the settings in your app manifest and a separate XML configuration file.
     86 Before adding Auto features to your app, you must first define the Auto
     87 XML configuration file and add a manifest entry referencing your XML file.</p>
     88 
     89 <h4 id="auto_xml">Define the Auto XML configuration file</h4>
     90 <p>Specify the car capabilities that your app uses in an XML file that you
     91 place in your projects resources directory ({@code res/xml/}). For example, to
     92 extend an audio application for Auto, create a file called
     93 {@code automotive_app_desc.xml} and store it under your projectss
     94 {@code res/xml/} folder. The {@code automotive_app_desc.xml} file contains the
     95 following metadata:</p>
     96 <pre>
     97 &lt;automotiveApp&gt;
     98    &lt;uses name="media" /&gt;
     99 &lt;/automotiveApp&gt;
    100 </pre>
    101 <p>The {@code <uses>} element declares the Auto capability your app
    102 intends to use. Multiple {@code <uses>} tags can be added if your
    103 application uses multiple car capabilities. The {@code name} attribute indicates
    104 the specific capability your app uses. The values supported are:</p>
    105 <ul>
    106 <li>{@code media} - The app uses the Android framework APIs to play music in
    107 a vehicle. Set this value if you are enabling an audio app for Auto.</li>
    108 <li>{@code notification} - The app displays message notifications in the cars
    109 Overview screen, allows users select a message to be read aloud, and lets them
    110 respond through voice input. Set this value if you are enabling a messaging
    111 app for Auto.
    112 </ul>
    113 
    114 <h4 id="auto_xml">Add a manifest entry</h4>
    115 <p>In your apps manifest ({@code AndroidManifest.xml}), provide a reference to
    116 the Auto XML configuration file you created in the previous section. Add a
    117 {@code "com.google.android.gms.car.application"} metadata entry under the
    118 <a href="{@docRoot}guide/topics/manifest/application-element.html">{@code <application>}</a>
    119 element that references your Auto XML configuration file. Omit the {@code .xml}
    120 file extension when specifying the configuration filename.</p>
    121 <p>The following code snippet shows how to include this reference in your
    122 manifest.</p>
    123 <pre>
    124 &lt;application&gt;
    125 
    126     ...
    127     &lt;meta-data android:name="com.google.android.gms.car.application"
    128      android:resource="@xml/automotive_app_desc"/&gt;
    129 
    130 &lt;/application&gt;
    131 </pre>
    132 
    133 <h2 id="build-it">Add Auto Features to Your Apps</h2>
    134 <p>After you have completed the steps described above, you're ready to add Auto
    135 features to your apps. See these additional topics to help you build apps for
    136 Auto:</p>
    137 
    138 <ul>
    139 <li><a href="{@docRoot}training/auto/audio/index.html">Providing Audio Playback for Auto</a>
    140 - Create apps that let users browse and play music in the car.</li>
    141 <li><a href="{@docRoot}training/auto/messaging/index.html">Providing Messaging for Auto</a>
    142 - Enable users to receive and reply to messages in the car.</li>
    143 </ul>
    144 
    145 <p class="caution"><strong>Important:</strong> Google takes driver distraction
    146 very seriously. There are specific design requirements your app must meet to
    147 qualify as an Auto app on Google Play. By adhering to these
    148 requirements, you can reduce the effort for building and testing your app. For
    149 more information, see
    150 <a href="{@docRoot}distribute/essentials/quality/auto.html">Auto App Quality</a>.</p>
    151 
    152 
    153 
    154 
    155