Automotive Developer Reference
Here are some tools to help you implement some of the features specific to Automotive.
Developer Tools and Tips
Touch Mode
When a user touches the device, touch mode begins. Here are some tools to interact with touch mode.
Detect Touch Mode
Android provides several ways to detect touch mode:
-
View.IsInTouchMode()
- This method, in the View class, can tell if the device is currently in touch mode. focusableInTouchMode:false
- This attribute can be set using XML for any view, or it can be done using thesetFocusableInTouchMode(false)
method.ViewTreeObserver.OnTouchModeChangeListener
- Android provides an API to listen for the change to and from touch mode, which can be used to change the UI, if needed.
Listen for Touch Mode Changes
Here is how you listen to touch mode changes:
view.getViewTreeObserver().addOnTouchModeChangeListener(
new ViewTreeObserver.OnTouchModeChangeListener() {
@Override
public void onTouchModeChanged(boolean b) {
// on touch mode change
}
});
Color Options
You can choose different colors depending on the view state. The following view states are available:
- Activated
- Focused
- Selected
Other Developer Tips
- When a user downloads an item in the app, pass along that information to the new Fire TV Downloader app via the Automotive SDK (described in next section). This is built to surface content in the Fire TV UI (outside the app), for ease of access and increased engagement with your apps.
- When a user deletes a downloaded item in your app, pass along that information with Fire TV via the SDK so the customer no longer sees this item on the Fire TV UI (outside the app).
- When a user on the RSE (Rear Seat Entertainment) starts/pauses/resumes/stops the playback of an item using an API, update the current playing item and playback status.
Automotive SDK Implementation
The Automotive SDK is to be used by app developers to integrate with Automotive features not available for the living room version of Fire TV. These feature include:
- Publishing/managing downloaded content on the Fire TV UI
- Updating playback status for front seat controls
Download Items
Add Download Items
You can add a download using the addDownloadedItem
method:
/**
* Use this method to add a downloaded item to device downloads,
* after the item download has finished.
*
* @param downloadedItem - MediaMetadata object for the downloaded item
* @param launchIntent - Intent to launch the downloaded item
* @param deleteIntent - Intent to remove the downloaded item from device downloads.
* On start of this intent, the downloaded item should be
* removed from the device
*/
public void addDownloadedItem (MediaMetadata downloadedItem,
Intent launchIntent, Intent deleteIntent)
Parameter | Description |
---|---|
MediaMetadata downloadedItem |
Displays details in the Downloads row/ Front Seat Control/ Download management page. These include:
|
launchIntent |
Launches the item from the Downloads row/ Front Seat Control/ Download management page. It can launch the in-app detail page or the player. |
deleteIntent |
Removes the downloaded items from the app (Quick Menu items in the Downloads Row / Download management page). |
Remove Download Items
The removeDownloadedItem
can help you remove a downloaded item:
/**
* Use this method to remove a downloaded item from device downloads,
* after the item download has been removed from the app.
*
* @param itemId - id to identify the downloaded Item
*/
public void removeDownloadedItem (String itemId)
The Item ID (itemId
) is used to identify the item to be removed from the Downloads Row/ Front Seat Control / Download management page.
Update the Playback Status
Use the updatePlaybackStatus
method to update the playback status of your app:
/**
* Use this method to update the current playing media on this device
*
* @param metadata - MediaMetadata object for the content currently playing
* @param state - current playback state for the content
* @param currentPlaybackTime - current time of playback
*/
public void updatePlaybackStatus (MediaMetadata metadata,
PlaybackState state, long currentPlaybackTime)
Parameter | Description |
---|---|
MediaMetadata metadata |
Displays the details on the Front Seat Controls. These details can include:
|
PlaybackState state |
These playback states are available: Playing, Paused, Stopped, and Started. |
currentPlaybackTime |
The current time of playback. |
Last updated: Jun 28, 2021