android.media.tv.TvContract.Channels Java Examples
The following examples show how to use
android.media.tv.TvContract.Channels.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModelUtils.java From xipl with Apache License 2.0 | 6 votes |
/** * Returns the current list of channels your app provides. * * @param resolver Application's ContentResolver. * @return List of channels. */ public static List<Channel> getChannels(ContentResolver resolver) { List<Channel> channels = new ArrayList<>(); // TvProvider returns programs in chronological order by default. Cursor cursor = null; try { cursor = resolver.query(Channels.CONTENT_URI, Channel.PROJECTION, null, null, null); if (cursor == null || cursor.getCount() == 0) { return channels; } while (cursor.moveToNext()) { channels.add(Channel.fromCursor(cursor)); } } catch (Exception e) { Log.w(TAG, "Unable to get channels", e); } finally { if (cursor != null) { cursor.close(); } } return channels; }
Example #2
Source File: ModelUtils.java From androidtv-sample-inputs with Apache License 2.0 | 6 votes |
/** * Returns the current list of channels your app provides. * * @param resolver Application's ContentResolver. * @return List of channels. */ public static List<Channel> getChannels(ContentResolver resolver) { List<Channel> channels = new ArrayList<>(); // TvProvider returns programs in chronological order by default. Cursor cursor = null; try { cursor = resolver.query(Channels.CONTENT_URI, Channel.PROJECTION, null, null, null); if (cursor == null || cursor.getCount() == 0) { return channels; } while (cursor.moveToNext()) { channels.add(Channel.fromCursor(cursor)); } } catch (Exception e) { Log.w(TAG, "Unable to get channels", e); } finally { if (cursor != null) { cursor.close(); } } return channels; }
Example #3
Source File: TvContractUtils.java From ChannelSurfer with MIT License | 5 votes |
public static LongSparseArray<Channel> buildChannelMap(ContentResolver resolver, String inputId, List<Channel> channels) { Uri uri = TvContract.buildChannelsUriForInput(inputId); String[] projection = { TvContract.Channels._ID, TvContract.Channels.COLUMN_DISPLAY_NUMBER }; LongSparseArray<Channel> channelMap = new LongSparseArray<>(); Cursor cursor = null; try { cursor = resolver.query(uri, projection, null, null, null); if (cursor == null || cursor.getCount() == 0) { return null; } while (cursor.moveToNext()) { long channelId = cursor.getLong(0); Log.d(TAG, "BUILD CHANNELS FOR "+channelId); String channelNumber = cursor.getString(1); channelMap.put(channelId, getChannelByNumber(channelNumber, channels)); } } catch (Exception e) { Log.d(TAG, "Content provider query: " + e.getStackTrace()); return null; } finally { if (cursor != null) { cursor.close(); } } return channelMap; }