# WatchNextProgram

Artifact: [androidx.tvprovider:tvprovider](https://developer.android.com/jetpack/androidx/releases/tvprovider) [View Source](https://cs.android.com/search?q=file:androidx/tvprovider/media/tv/WatchNextProgram.java+class:androidx.tvprovider.media.tv.WatchNextProgram) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

*** ** * ** ***


```
public final class WatchNextProgram
```

<br />

*** ** * ** ***

A convenience class to access `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.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 `https://developer.android.com/reference/androidx/tvprovider/media/tv/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 https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram.Builder` This Builder class simplifies the creation of a `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram` object. |

| ### Constants |
|---|---|
| `static final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html String[]` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#PROJECTION()` The projection for a `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram` query. |
| `static final int` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#WATCH_NEXT_TYPE_UNKNOWN() = -1` The unknown watch next type. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `static https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#fromCursor(android.database.Cursor)(https://developer.android.com/reference/android/database/Cursor.html cursor)` Creates a WatchNextProgram object from a cursor including the fields defined in `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.WatchNextPrograms`. |
| `long` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#getLastEngagementTimeUtcMillis()()` |
| `int` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#getWatchNextType()()` |
| `boolean` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#hasAnyUpdatedValues(androidx.tvprovider.media.tv.WatchNextProgram)(https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram update)` Indicates whether some other WatchNextProgram has any set attribute that is different from this WatchNextProgram's respective attributes. |
| `https://developer.android.com/reference/android/content/ContentValues.html` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#toContentValues()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#toString()()` |

## Constants

### PROJECTION

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public static final @NonNull String[] PROJECTION
```

The projection for a `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram` query.

This provides a array of strings containing the columns to be used in the query and in creating a Cursor object, which is used to iterate through the rows in the table.

### WATCH_NEXT_TYPE_UNKNOWN

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
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](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public static WatchNextProgram fromCursor(Cursor cursor)
```

Creates a WatchNextProgram object from a cursor including the fields defined in `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.WatchNextPrograms`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/database/Cursor.html cursor` | A row from the TV Input Framework database. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram` | A Program with the values taken from the cursor. |

### getLastEngagementTimeUtcMillis

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public long getLastEngagementTimeUtcMillis()
```

| Returns |
|---|---|
| `long` | The value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.WatchNextPrograms#COLUMN_LAST_ENGAGEMENT_TIME_UTC_MILLIS()` for the program. |

### getWatchNextType

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public int getWatchNextType()
```

Value is one of the following:

- `WatchNextPrograms.WATCH_NEXT_TYPE_CONTINUE`
- `WatchNextPrograms.WATCH_NEXT_TYPE_NEXT`
- `WatchNextPrograms.WATCH_NEXT_TYPE_NEW`
- `WatchNextPrograms.WATCH_NEXT_TYPE_WATCHLIST`

<br />

| Returns |
|---|---|
| `int` | The value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.WatchNextPrograms#COLUMN_WATCH_NEXT_TYPE()` for the program, or `https://developer.android.com/reference/androidx/tvprovider/media/tv/WatchNextProgram#WATCH_NEXT_TYPE_UNKNOWN()` if it's unknown. |

### hasAnyUpdatedValues

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
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](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public ContentValues toContentValues()
```

| Returns |
|---|---|
| `https://developer.android.com/reference/android/content/ContentValues.html` | The fields of the Program in the ContentValues format to be easily inserted into the TV Input Framework database. |

### toString

```
public String toString()
```