CarAppService

public abstract class CarAppService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ androidx.car.app.CarAppService


The base class for implementing a car app that runs in the car.

Service Declaration

The app must extend the CarAppService to be bound by the car host. The service must also respond to Intent actions coming from the host, by adding an intent-filter to the service in the AndroidManifest.xml that handles the SERVICE_INTERFACE action. The app must also declare what category of application it is (e.g. CATEGORY_NAVIGATION_APP). For example:
<service
   android:name=".YourAppService"
   android:exported="true">
   <intent-filter>
     <action android:name="androidx.car.app.CarAppService" />
     <category android:name="androidx.car.app.category.NAVIGATION"/>
   </intent-filter>
 </service>
 

For a list of all the supported categories see Supported App Categories.

Accessing Location

When the app is running in the car display, the system will not consider it as being in the foreground, and hence it will be considered in the background for the purpose of retrieving location as described here.

To reliably get location for your car app, we recommended that you use a foreground service. If you have a service other than your CarAppService that accesses location, run the service and your `CarAppService` in the same process. Also note that accessing location may become unreliable when the phone is in the battery saver mode.

Summary

Constants

String CATEGORY_CHARGING_APP

Used to declare that this app is a charging app in the manifest.

String CATEGORY_NAVIGATION_APP

Used to declare that this app is a navigation app in the manifest.

String CATEGORY_PARKING_APP

Used to declare that this app is a parking app in the manifest.

String SERVICE_INTERFACE

The full qualified name of the CarAppService class.

Inherited constants