Example usage for android.media.tv TvContract buildProgramsUriForChannel

List of usage examples for android.media.tv TvContract buildProgramsUriForChannel

Introduction

In this page you can find the example usage for android.media.tv TvContract buildProgramsUriForChannel.

Prototype

public static Uri buildProgramsUriForChannel(Uri channelUri) 

Source Link

Document

Builds a URI that points to all programs on a given channel.

Usage

From source file:Main.java

public static long getLastProgramEndTimeMillis(ContentResolver resolver, Uri channelUri) {
    Uri uri = TvContract.buildProgramsUriForChannel(channelUri);
    String[] projection = { Programs.COLUMN_END_TIME_UTC_MILLIS };
    Cursor cursor = null;/*  w w  w  .j a v a2s  . co m*/
    try {
        // TvProvider returns programs chronological order by default.
        cursor = resolver.query(uri, projection, null, null, null);
        if (cursor == null || cursor.getCount() == 0) {
            return 0;
        }
        cursor.moveToLast();
        return cursor.getLong(0);
    } catch (Exception e) {
        Log.w(TAG, "Unable to get last program end time for " + channelUri, e);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return 0;
}