CarAppActivity

public final class CarAppActivity
extends FragmentActivity

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.view.ContextThemeWrapper
         ↳ android.app.Activity
           ↳ androidx.activity.ComponentActivity
             ↳ androidx.fragment.app.FragmentActivity
               ↳ androidx.car.app.activity.CarAppActivity


The class representing a car app activity.

This class is responsible for binding to the host and rendering the content given by its CarAppService.

Usage of CarAppActivity is only required for applications targeting Automotive OS.

Activity Declaration

The app must declare and export this CarAppActivity in their manifest. In order for it to show up in the car's app launcher, it must include a Intent.CATEGORY_LAUNCHER intent filter. For example:

<activity
   android:name="androidx.car.app.activity.CarAppActivity"
   android:exported="true"
   android:label="@string/your_app_label">

   <intent-filter>
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
   <meta-data android:name="distractionOptimized" android:value="true"/>
 </activity>
 

See CarAppService for how to declare your app's CarAppService in the manifest.

Distraction-optimized Activities

The activity must be the distractionOptimized meta-data set to true, in order for it to be displayed while driving. This is the only activity that can have this meta-data set to true, any other activities marked this way may cause the app to be rejected during app submission.

Summary

Inherited constants

Inherited fields

Public constructors

CarAppActivity()

Public methods

void onBackPressed()

Called when the activity has detected the user's press of the back key.

Protected methods

void onCreate(Bundle savedInstanceState)

If your ComponentActivity is annotated with ContentView, this will call setContentView(int) for you. Perform initialization of all fragments.

void onDestroy()

Destroy all fragments.

void onNewIntent(Intent intent)

Handle onNewIntent() to inform the fragment manager that the state is not saved.

Inherited methods