WatchNextProgram


public final class WatchNextProgram


A convenience class to access WatchNextPrograms entries in the system content provider.

This class makes it easy to insert or retrieve a program from the system content provider, which is defined in TvContractCompat.

Usage example when inserting a "watch next" program:

WatchNextProgram watchNextProgram = new WatchNextProgram.Builder()
        .setWatchNextType(WatchNextPrograms.WATCH_NEXT_TYPE_CONTINUE)
        .setType(PreviewPrograms.TYPE_MOVIE)
        .setTitle("Program Title")
        .setDescription("Program Description")
        .setPosterArtUri(Uri.parse("http://example.com/poster_art.png"))
        // Set more attributes...
        .build();
Uri watchNextProgramUri = getContentResolver().insert(WatchNextPrograms.CONTENT_URI,
        watchNextProgram.toContentValues());

Usage example when retrieving a "watch next" program:

WatchNextProgram watchNextProgram;
try (Cursor cursor = resolver.query(watchNextProgramUri, null, null, null, null)) {
    if (cursor != null && cursor.getCount() != 0) {
        cursor.moveToNext();
        watchNextProgram = WatchNextProgram.fromCursor(cursor);
    }
}

Usage example when updating an existing "watch next" program:

WatchNextProgram updatedProgram = new WatchNextProgram.Builder(watchNextProgram)
        .setLastEngagementTimeUtcMillis(System.currentTimeMillis())
        .build();
getContentResolver().update(TvContractCompat.buildWatchNextProgramUri(updatedProgram.getId()),
        updatedProgram.toContentValues(), null, null);

Usage example when deleting a "watch next" program:

getContentResolver().delete(TvContractCompat.buildWatchNextProgramUri(existingProgram.getId()),
        null, null);

Summary

Nested types

public final class WatchNextProgram.Builder

This Builder class simplifies the creation of a WatchNextProgram object.

Constants

static final int

The unknown watch next type.

Public methods

boolean
equals(Object other)
static WatchNextProgram

Creates a WatchNextProgram object from a cursor including the fields defined in WatchNextPrograms.

long
int
boolean

Indicates whether some other WatchNextProgram has any set attribute that is different from this WatchNextProgram's respective attributes.

ContentValues
String

Constants

WATCH_NEXT_TYPE_UNKNOWN

Added in 1.1.0-alpha02
public static final int WATCH_NEXT_TYPE_UNKNOWN = -1

The unknown watch next type. Use this type when the actual type is not known.

Public methods

equals

public boolean equals(Object other)

fromCursor

Added in 1.1.0-alpha02
public static WatchNextProgram fromCursor(Cursor cursor)

Creates a WatchNextProgram object from a cursor including the fields defined in WatchNextPrograms.

Parameters
Cursor cursor

A row from the TV Input Framework database.

Returns
WatchNextProgram

A Program with the values taken from the cursor.

getLastEngagementTimeUtcMillis

Added in 1.1.0-alpha02
public long getLastEngagementTimeUtcMillis()
Returns
long

The value of COLUMN_LAST_ENGAGEMENT_TIME_UTC_MILLIS for the program.

getWatchNextType

Added in 1.1.0-alpha02
public int getWatchNextType()
Returns
int

The value of COLUMN_WATCH_NEXT_TYPE for the program, or WATCH_NEXT_TYPE_UNKNOWN if it's unknown.

hasAnyUpdatedValues

Added in 1.1.0-alpha02
public boolean hasAnyUpdatedValues(WatchNextProgram update)

Indicates whether some other WatchNextProgram has any set attribute that is different from this WatchNextProgram's respective attributes. An attribute is considered "set" if its key is present in the ContentValues vector.

toContentValues

Added in 1.1.0-alpha02
public ContentValues toContentValues()
Returns
ContentValues

The fields of the Program in the ContentValues format to be easily inserted into the TV Input Framework database.

toString

public String toString()