Class CarApplication
The entry point an app implements to provide its in-car (Apple CarPlay / Google Android Auto)
experience. Register a single instance with Car#setApplication(CarApplication) from your app's
init() so it is in place before a head unit connects:
public void init(Object ctx) {
// ... normal app init ...
Car.setApplication(new MyCarApplication());
}
class MyCarApplication extends CarApplication {
public CarScreen onCreateRootScreen(CarContext context) {
return new LibraryScreen();
}
}
Referencing any com.codename1.car type is what tells the build to wire the native in-car
support (CarPlay scene + entitlement, Android Auto CarAppService + dependency); apps that never
touch the package pay nothing. The app must also be in a head-unit-eligible category and declare
it via build hints (see the category hints in the developer guide).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonCarConnected(CarContext context) Invoked after the root screen is created, when the connection is fully established.voidInvoked when the head unit disconnects and the in-car experience ends.abstract CarScreenonCreateRootScreen(CarContext context) Builds the root screen shown when a head unit connects.
-
Constructor Details
-
CarApplication
public CarApplication()
-
-
Method Details
-
onCreateRootScreen
Builds the root screen shown when a head unit connects. Called once per connection.
Parameters
context: the live car context for the connected head unit
Returns
the root
CarScreen; must be non-null -
onCarConnected
Invoked after the root screen is created, when the connection is fully established. Default is a no-op; override for one-off setup (start playback, begin a location stream).
Parameters
context: the live car context
-
onCarDisconnected
public void onCarDisconnected()Invoked when the head unit disconnects and the in-car experience ends. Default is a no-op; override to release car-only resources.
-