8

I'm an Android developer and I'm trying to develop a custom Android Auto app, that does a simple mirroring of the phone screen. I know that currently the API are only available for music and messaging apps, but I would write an app for mirror a simple "hello world". I follow the Google Getting Started tutorial and I'm using the Desktop Head Unit (DHU) provided by Google (at developer.android.com/training/auto/testing/index.html)

but when I tap last button on the bottom of the display and select "All car apps", my application doesn't appear on the list.

All car apps

For example, if Android Auto is launched in a Samsung tablet (SM-T555), the DHU lists these app:

com.google.android.gms, Maps, System UI, Video, SampleAuthenticatorService, SecureSampleAuthService, Screen capture, Android Auto, Phone, Media, Return to Google, Samsung Billing, Google App, Google Play Music, Music

Available Car Apps in a Samsung Tablet

How can I make an app that is displayed on the available app list in Android Auto? Is possible do mirroring for a custom app in Android Auto?

Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
DemoneCT
  • 91
  • 1
  • 1
  • 3

4 Answers4

17

Create a service like this:

public class HelloWorldService extends CarActivityService {

    @Override
    public Class<? extends CarActivity> getCarActivity() {
        return HelloWorldAutoActivity.class;
    }
}

Then add the service to your manifest like this:

    <meta-data
        android:name="com.google.android.gms.car.application"
        android:resource="@xml/automotive_app_desc" />

    <service
        android:name=".HelloWorldService"
        android:exported="true"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="com.google.android.gms.car.category.CATEGORY_PROJECTION" />
            <category android:name="com.google.android.gms.car.category.CATEGORY_PROJECTION_OEM" />
        </intent-filter>
    </service>

Finally create a xml file called automotive_app_desc under your res folder:

<automotiveApp>
    <uses name="service" />
    <uses name="projection" />
    <uses name="notification" />
</automotiveApp>

Your HelloWorldAutoActivity.class will work as your MainActivity.

Aldo López
  • 431
  • 1
  • 4
  • 9
  • Can you please provide info where is: CarActivityService from? I dont see any service in Android with that name. Also you didnt mentioned that you need Activity that extends CarActivity? There is this class coming from? – Dominik Mičuta Jun 12 '17 at 14:30
  • You need to extract and make a dex2jar from Android Auto, then import it in your project and set it as file dependency – Emil Borconi Jul 03 '17 at 12:37
  • @EmilBorconi Did you have trouble linking converted dex to your project?..... I'm getting a error where gradle says it could not extract zip file to the tmp dir..... – J1and1 Jul 17 '17 at 13:11
  • Yes I did unfortunately and haven't got the time to look more into it. On the other had I heard that one of the VW group (Skoda or Seat) have just launched the first app which uses the 5th tab in AA. I will need to find it and try to extract the dex files from it and reverse them to see what can be achieved and what library they are linking against. – Emil Borconi Jul 17 '17 at 18:42
  • 2
    @J1and1 - Try to use this jar: https://app.box.com/s/v13xfv32qtkdafo4splwltime6ut4l22 and import it like this: import com.google.android.apps.auto.sdk.*; I had no chance to look into available classes/functions/etc as it's reverseengenering don't expect any official support – Emil Borconi Jul 30 '17 at 23:22
  • @EmilBorconi Thanks for the Jar. It works like a charm..... Will need to do some reaserch with Java decompiler to figure out some minor things that I need for my project... this put me a step closer..... Thanks again!!!!!! – J1and1 Aug 09 '17 at 08:04
  • 1
    @J1and1 You're welcome, if you do manage to find out some things, I'll like to hear about it. I haven't got the time yet to start digging into it but hopefully will do myself in the near future. – Emil Borconi Aug 09 '17 at 12:20
  • @EmilBorconi would you mind looking into this again? The old version doesn't seem to work anymore. I did convert the new apk to a jar, but the whole sdk part is gone, as far as I can see. However, there seem to be whole apps bundled into the AA apk now, like `com.seat.connectedcar`, but I'm not yet skilled enough to understand if we could reuse that parts somehow – Kimmax May 03 '19 at 15:52
  • @Kimmax - almost pointless, as Google is blocking any non media/messages apps. – Emil Borconi May 09 '19 at 12:34
  • 1
    I have this error when : `Cannot access 'android.view.LayoutInflater$Factory' which is a supertype of 'com.example.app.ui.AutoActivity'. Check your module classpath for missing or conflicting dependencies Cannot access 'com.google.android.gms.car.CarActivityHost$HostedCarActivity' which is a supertype of 'com.example.app.ui.AutoActivity'. Check your module classpath for missing or conflicting dependencies` – user924 Apr 04 '22 at 08:58
0

Android auto not customized. some api (audio, map, contacts) are same, customized.but you can dolittle things. pls check this https://github.com/Mutesham/AndroidAuto_TextApp

-1

In order to have app displayed on the Auto. You will have to upload it to playstore on beta channel.

vishalpa
  • 99
  • 1
  • 4
-10

The Main Activity File

The main activity code is a Java file MainActivity.java. This is the actual application file which ultimately gets converted to a Dalvik executable and runs your application. Following is the default code generated by the application wizard for Hello World! application −

package com.example.helloworld;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
}

The Manifest File

Whatever component you develop as a part of your application, you must declare all its components in a manifest.xml which resides at the root of the application project directory. This file works as an interface between Android OS and your application, so if you do not declare your component in this file, then it will not be considered by the OS. For example, a default manifest file will look like as following file −

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.tutorialspoint7.myapplication">

   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">

      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>

The Strings File

The strings.xml file is located in the res/values folder and it contains all the text that your application uses. For example, the names of buttons, labels, default text, and similar types of strings go into this file. This file is responsible for their textual content. For example, a default strings file will look like as following file −

<resources>
   <string name="app_name">HelloWorld</string>
   <string name="hello_world">Hello world!</string>
   <string name="menu_settings">Settings</string>
   <string name="title_activity_main">MainActivity</string>
</resources>

The Layout File

The activity_main.xml is a layout file available in res/layout directory, that is referenced by your application when building its interface. You will modify this file very frequently to change the layout of your application. For your "Hello World!" application, this file will have following content related to default layout −

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent" >

   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:padding="@dimen/padding_medium"
      android:text="@string/hello_world"
      tools:context=".MainActivity" />

</RelativeLayout>
  • 3
    This answer is a complete miss and does not even come close to addressing the question. This answer would be great if the question were "how do I create a hello world app for Android?" But this question is asking about Android Auto, which is a specific API for integrating apps to use with an Android Auto compatible head unit. This answer should be deleted. – Thomas Carlisle Nov 26 '18 at 16:09
  • this does not answer his question at all? – markharrop Feb 12 '21 at 09:25
  • Appears to be plagiarised from https://www.tutorialspoint.com/android/android_hello_world_example.htm – Wai Ha Lee Mar 10 '21 at 06:06