Android SDK Advanced Use Cases

The following page contains instructions on how to integrate using Android SDK for a few advanced use cases, such as reporting live program and playlist changes, fatal errors, etc.

Updated 2026-05-29 android, advanced, use, cases, sensor developer center, sensor integration

The following page contains instructions on how to integrate using Android SDK for a few advanced use cases, such as reporting live program and playlist changes, fatal errors, etc. After completing the initial stream sensor integration, use these instructions as an add-on to achieve specific goals.

Switching Between Landscape and Portrait Modes

If the user switches screen orientation during video playback, the video monitoring session should continue uninterrupted. The session is cleaned up only when the playback ends or the user explicitly closes the player.

Switching Between Full-screen and Picture-in-Picture (PiP) Modes

If a user switches between Full-screen and Picture-in-Picture (PiP) modes, the video monitoring session should continue uninterrupted. The session should be cleaned up when playback ends or the user explicitly closes the player.

Handling Casting

Casting must be treated as a playback context change. If the Chromecast/receiver integrates Conviva, create and maintain the monitoring session on the receiver. When casting starts during sender playback, terminate the sender session at handoff and create a new receiver session for Chromecast playback.

Report Live, Live Linear, or FAST Program Changes

Report program changes during live, live linear, or FAST streaming

Users may switch from one program to another at the program boundary either during live or live linear streaming. To report such changes, use the videoAnalytics.setContentInfo(newContentInfo) API and update the asset namee that has changed at the program boundary.

The following is the sample code:

// update ASSET_NAME and any other metadata that has changed.
Map<String, Object> newContentInfo = new HashMap<>();
newContentInfo.put(ConvivaSdkConstants.ASSET_NAME, "Asset name of the next program");
videoAnalytics.setContentInfo(newContentInfo);

Report Playlist Changes

Report video changes in playlist

Users may switch from one playlist item to another during streaming. To report these changes, close the previous session and open a new session. Then, set the metadata using the videoAnalytics.setContentInfo(newContentInfo) API.

The following is the sample code:

// close the previous session
...
// open a new session with new metadata
...
Map<String, Object> newContentInfo = new HashMap<>();
newContentInfo.put(ConvivaSdkConstants.ASSET_NAME, "Next playlist item");

// reset any irrelevant or unavailable metadata by updating it with an empty string("").
newContentInfo.put(<any_metadata>, "");
videoAnalytics.setContentInfo(newContentInfo);

Stop Auto-Reporting Errors from ExoPlayer and Media3 Modules

Configure the ExoPlayer and Media3 modules to stop auto-reporting fatal player errors by passing ConvivaSdkConstants.PLAYBACK.AUTO_REPORT_ERRORS in the player's info through the ConvivaVideoAnalytics.setPlayer API.

With this setup, the ExoPlayer and Media3 modules stop reporting the errors, unless the errors are reported exclusively through the convivaVideoAnalytics.reportPlaybackError API.

The following is the sample code:

HashMap<String, Object> playerInfo = new HashMap<>();

// Indicate to the ExoPlayer/Media3 module that errors should not be auto reported

playerInfo.put(ConvivaSdkConstants.PLAYBACK.AUTO_REPORT_ERRORS, false);
client.setPlayer(player, playerInfo);

Report Errors

Playback does not recover from error and is reported once only

Playback encounters a fatal error from which it does not recover. Use the videoAnalytics.reportPlaybackFailed(errorMessage, contentInfo) API to report this to Conviva, so that Conviva can close the monitoring session.

The following is the sample code:

videoAnalytics.reportPlaybackFailed(errorMessage, contentInfo);

Retry - Playback does not recover from error and fatal errors are reported multiple times

Playback encounters an initial fatal error from which it does not recover. However, an application or player timeout triggers a retry behavior. In such a use case, invoke the videoAnalytics.reportPlaybackError(errorMessage, ConvivaSdkConstants.ErrorSeverity.FATAL) API to report each error to Conviva, so that Conviva can keep the session active until all retry attempts are exhausted. When no more retries are available from the application's perspective, the Conviva monitoring session is closed.

The following is the sample code:

// retry attempt 1, after first fatal error
videoAnalytics.reportPlaybackError(errorMessage_1, ConvivaSdkConstants.ErrorSeverity.FATAL);
// retry attempt 2, after second fatal error
videoAnalytics.reportPlaybackError(errorMessage_2, ConvivaSdkConstants.ErrorSeverity.FATAL);
// retry attempt 3, after 3rd fatal error
videoAnalytics.reportPlaybackError(errorMessage_3, ConvivaSdkConstants.ErrorSeverity.FATAL);
.
.
// retry attempt n, after nth fatal error and the app has no more retries
videoAnalytics.reportPlaybackError(errorMessage_n, ConvivaSdkConstants.ErrorSeverity.FATAL);
videoAnalytics.reportPlaybackEnded();

Playback recovers from a fatal error by switching to a different asset URL

Playback has encountered an error and on retrying with a different asset url, it recovered during the same playback session. In such cases, use the videoAnalytics.reportPlaybackError(errorMessage, ConvivaSdkConstants.ErrorSeverity.FATAL) API to report the error and videoAnalytics.setContentInfo(newContentInfo) API to update the stream URL once the playback has recovered.

The following is the sample code:

videoAnalytics.reportPlaybackError(errorMessage, ConvivaSdkConstants.ErrorSeverity.FATAL);
..
Map<String, Object> newContentInfo = new HashMap<>();
newContentInfo.put(ConvivaSdkConstants.STREAM_URL, "UPDATED_STREAM_URL");
videoAnalytics.setContentInfo(newContentInfo);

Playback recovery in multi CDN scenario

Playback has encountered an error and on retrying with a different CDN, it recovered during the same playback session. In such cases, use the videoAnalytics.reportPlaybackError(errorMessage, ConvivaSdkConstants.ErrorSeverity.FATAL) API to report the error and videoAnalytics.setContentInfo(newContentInfo) API to update the stream URL corresponding to the newer CDN once the playback has recovered.

The following is the sample code:

videoAnalytics.reportPlaybackError(errorMessage, ConvivaSdkConstants.ErrorSeverity.FATAL);
..
Map<String, Object> newContentInfo = new HashMap<>();
newContentInfo.put(ConvivaSdkConstants.STREAM_URL, "UPDATED_STREAM_URL");
videoAnalytics.setContentInfo(newContentInfo);

Playback is not impacted due to a warning error type

The player or application encountered an error that does not impact video playback. However, if you still want to report it, then ensure to report it as WARNING. Invoke the videoAnalytics.reportPlaybackError(errorMessage, ConvivaSdkConstants.ErrorSeverity.WARNING) API to report the error severity as a warning.

The following is the sample code:

videoAnalytics.reportPlaybackError(errorMessage, ConvivaSdkConstants.ErrorSeverity.WARNING);

Optimize Monitoring During User Wait State

User Actions: User Dialogues

Conviva prefers to optimize certain portions of monitoring during user wait state, so that it does not inaccurately reflect in metrics like VST. For that, monitoring must be turned off when video playback request is halted due to user dialogues like:

  • pin popup

  • accepting strong language or violence

  • confirming age

  • startover or resume dialogue

  • watch party initiation

These user dialogues can be handled using the following APIs:

On user wait started:

videoAnalytics.reportPlaybackEvent(ConvivaSdkConstants.Events.USER_WAIT_STARTED.toString());

On user wait ended:

videoAnalytics.reportPlaybackEvent(ConvivaSdkConstants.Events.USER_WAIT_ENDED.toString());

User Actions: Backgrounding and Foregrounding

To handle backgrounding events (for example, pressing home or power off buttons), use:

ConvivaAnalytics.reportAppBackgrounded();

To handle foregrounding events:

ConvivaAnalytics.reportAppForegrounded();
It's not required to close the previous session and open a new session. Ensure that the player states are accurately reported before backgrounding and after foregrounding.

Conviva Android Core SDK v4.0.32 and above versions autocollect the app backgrounding and foregrounding events.