Download source code of this article.

Car mode in Android is a UI mode that is invoked when the device is connected to the car dock. An application can programmatically switch to this mode by using UiModeManager.enterCarMode() method with UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME parameter. This a safer way to access the applications while driving. Android has introduced a new application “Car Home” from 2.2 onwards. This is a default car mode application. Car Home application provides you a quick access to selected applications and supports customization also. You can add shortcuts of the application that supports car mode. To support car mode an application has to specify the category “android.intent.category.CAR_MODE” in AndroidManifest.xml file. By specifying this category we can tell the system that our application supports car mode and a user will be able to create shortcut of the application.

We can create our own custom car mode application by specifying the category “android.intent.category.CAR_DOCK” in AndroidManifest.xml file and thereby override the default “Car Home” application. But we have to take extra care to make it usable and safer while driving.

The sample application is a very simple and minimal that just shows information text and does nothing. If you press the BACK key the application will exit from the car mode by using UiModeManager.disableCarMode() with passing UiModeManager.DISABLE_CAR_MODE_GO_HOME as parameter.