# ChannelLogoUtils

# ChannelLogoUtils

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/ChannelLogoUtils.java+class:androidx.tvprovider.media.tv.ChannelLogoUtils)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/tvprovider/media/tv/ChannelLogoUtils "View this page in Java")

<br />

```
@WorkerThread
class ChannelLogoUtils
```

<br />

*** ** * ** ***

A utility class for conveniently storing and loading channel logos.

## Summary

|                                                                                                                   ### Public constructors                                                                                                                    |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ~~[ChannelLogoUtils](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/ChannelLogoUtils#ChannelLogoUtils())~~`()` **This function is deprecated.** This type should not be instantiated as it contains only static methods. <br /> |

|                                       ### Public functions                                        |
|---------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)`?`   | `@`[WorkerThread](https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread) [loadChannelLogo](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/ChannelLogoUtils#loadChannelLogo(android.content.Context,long))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, channelId: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` A convenient helper method to get the channel logo associated to the given channel ID from the system content provider.                                                                                                                                                                                 |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `@`[WorkerThread](https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread) [storeChannelLogo](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/ChannelLogoUtils#storeChannelLogo(android.content.Context,long,android.graphics.Bitmap))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, channelId: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, logo: `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)`)` Stores the given channel logo[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)in the system content provider and associate it with the given channel ID. |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [storeChannelLogo](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/ChannelLogoUtils#storeChannelLogo(android.content.Context,long,android.net.Uri))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, channelId: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, logoUri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`)` Stores channel logo in the system content provider from the given URI.                                                                                                                                                                                                                                   |

## Public constructors

### ChannelLogoUtils

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

```
[ChannelLogoUtils](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/ChannelLogoUtils#ChannelLogoUtils())()
```
| **This function is deprecated.**   
|
This type should not be instantiated as it contains only static methods.  

## Public functions

### loadChannelLogo

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

```
@WorkerThread
java-static fun loadChannelLogo(context: Context, channelId: Long): Bitmap?
```

A convenient helper method to get the channel logo associated to the given channel ID from the system content provider.  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html) | the context used to access the system content provider    |
| `channelId: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | the ID of the channel whose logo is supposed to be loaded |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| [Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)`?` | the requested channel logo in[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html), or`null`if not available. |

|                                                                                        See also                                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [storeChannelLogo](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/ChannelLogoUtils#storeChannelLogo(android.content.Context,long,android.net.Uri))         |   |
| [storeChannelLogo](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/ChannelLogoUtils#storeChannelLogo(android.content.Context,long,android.graphics.Bitmap)) |   |

### storeChannelLogo

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

```
@WorkerThread
java-static fun storeChannelLogo(context: Context, channelId: Long, logo: Bitmap): Boolean
```

Stores the given channel logo[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)in the system content provider and associate it with the given channel ID.  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html) | the context used to access the system content provider                      |
| `channelId: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | the ID of the target channel with which the given logo should be associated |
| `logo: `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)     | the logo image to be stored                                                 |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if successfully stored the logo in the system content provider, otherwise`false`. |

|                                                                           See also                                                                            |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [loadChannelLogo](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/ChannelLogoUtils#loadChannelLogo(android.content.Context,long)) |   |

### storeChannelLogo

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

```
java-static fun storeChannelLogo(context: Context, channelId: Long, logoUri: Uri): Boolean
```

Stores channel logo in the system content provider from the given URI. The method will try to fetch the image file and decode it into[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html). Once the image is successfully fetched, it will be stored in the system content provider and associated with the given channel ID.

The URI provided to this method can be a URL referring to a image file residing in some remote site/server, or a URI in one of the following formats:

- content ([SCHEME_CONTENT](https://developer.android.com/reference/android/content/ContentResolver.html#SCHEME_CONTENT()))
- android.resource ([#SCHEME_ANDROID_RESOURCE](https://developer.android.com/reference/android/content/ContentResolver.html))
- file ([SCHEME_FILE](https://developer.android.com/reference/android/content/ContentResolver.html#SCHEME_FILE()))

This method should be run in a worker thread since it may require network connection, which will raise an exception if it's running in the main thread.  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html) | the context used to access the system content provider                                                                                 |
| `channelId: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | the ID of the target channel with which the fetched logo should be associated                                                          |
| `logoUri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)             | the[Uri](https://developer.android.com/reference/android/net/Uri.html)of the logo file to be fetched and stored in the system provider |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if successfully fetched the image file referred by the give logo URI and stored it in the system content provider, or`false`if failed. |

|                                                                           See also                                                                            |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [loadChannelLogo](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/ChannelLogoUtils#loadChannelLogo(android.content.Context,long)) |   |