public abstract class CarApplication
- Object
- 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).
Constructors
public CarApplication() |
Methods
public abstract CarScreen onCreateRootScreen(CarContext context) | Builds the root screen shown when a head unit connects. |
public void onCarConnected(CarContext context) | Invoked after the root screen is created, when the connection is fully established. |
public void onCarDisconnected() | Invoked when the head unit disconnects and the in-car experience ends. |
Inherited methods
Constructor details
CarApplication
public CarApplication()Method details
onCreateRootScreen
public abstract CarScreen onCreateRootScreen(CarContext context)Builds the root screen shown when a head unit connects. Called once per connection.
Parameters
contextCarContext- the live car context for the connected head unit
Returns
the root
CarScreen; must be non-nullonCarConnected
public void onCarConnected(CarContext context)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
contextCarContext- 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.