Skip to content

Instantly share code, notes, and snippets.

@ademirqueiroga
Last active February 22, 2023 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ademirqueiroga/be780f7754ec2db2e5d6016ecda4c7cd to your computer and use it in GitHub Desktop.
Save ademirqueiroga/be780f7754ec2db2e5d6016ecda4c7cd to your computer and use it in GitHub Desktop.
Querying channel info with ContentResolver
private fun queryChannels(): List<Channel> {
val channels = ArrayList<Channel>()
context.contentResolver.query(
/* uri = */ TvContractCompat.Channels.CONTENT_URI,
/* projection = */ Channel.PROJECTION,
/* selection = */ null,
/* selectionArgs = */ null,
/* sortOrder = */ null
).use { cursor ->
while (cursor != null && cursor.moveToNext()) {
channels.add(Channel.fromCursor(cursor))
}
}
return channels
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment