Register now for Android Dev Summit 2019!

WatchNextProgram

class WatchNextProgram : BasePreviewProgram
androidx.tvprovider.media.tv.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 classes

This Builder class simplifies the creation of a WatchNextProgram object.

Constants

static Int

The unknown watch next type.

Public methods

Boolean
equals(other: Any?)

static WatchNextProgram!
fromCursor(cursor: Cursor!)

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

static val WATCH_NEXT_TYPE_UNKNOWN: Int

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

Value: -1

Public methods

equals

fun equals(other: Any?): Boolean

fromCursor

static fun fromCursor(cursor: Cursor!): WatchNextProgram!

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

Parameters
cursor Cursor!: A row from the TV Input Framework database.
Return
WatchNextProgram!: A Program with the values taken from the cursor.

getLastEngagementTimeUtcMillis

fun getLastEngagementTimeUtcMillis(): Long
Return
Long: The value of WatchNextPrograms#COLUMN_LAST_ENGAGEMENT_TIME_UTC_MILLIS for the program.

getWatchNextType

fun getWatchNextType(): Int
Return
Int: The value of WatchNextPrograms#COLUMN_WATCH_NEXT_TYPE for the program, or WATCH_NEXT_TYPE_UNKNOWN if it's unknown.

hasAnyUpdatedValues

fun hasAnyUpdatedValues(update: WatchNextProgram!): Boolean

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

fun toContentValues(): ContentValues!
Return
ContentValues!: The fields of the Program in the ContentValues format to be easily inserted into the TV Input Framework database.

toString

fun toString(): String