# 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)

*** ** * ** ***


```
@WorkerThread
public class ChannelLogoUtils
```

<br />

*** ** * ** ***

A utility class for conveniently storing and loading channel logos.

## Summary

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

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/Bitmap.html` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/tvprovider/media/tv/ChannelLogoUtils#loadChannelLogo(android.content.Context,long)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, long channelId)` A convenient helper method to get the channel logo associated to the given channel ID from the system content provider. |
| `static boolean` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/tvprovider/media/tv/ChannelLogoUtils#storeChannelLogo(android.content.Context,long,android.graphics.Bitmap)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, long channelId, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Bitmap.html logo )` Stores the given channel logo `https://developer.android.com/reference/android/graphics/Bitmap.html` in the system content provider and associate it with the given channel ID. |
| `static boolean` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/ChannelLogoUtils#storeChannelLogo(android.content.Context,long,android.net.Uri)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, long channelId, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html logoUri )` 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)

```
public [ChannelLogoUtils](https://developer.android.com/reference/androidx/tvprovider/media/tv/ChannelLogoUtils#ChannelLogoUtils())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> This type should not be instantiated as it contains only static methods.

## Public methods

### loadChannelLogo

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

```
@WorkerThread
public static @Nullable Bitmap loadChannelLogo(@NonNull Context context, long channelId)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | the context used to access the system content provider |
| `long channelId` | the ID of the channel whose logo is supposed to be loaded |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/Bitmap.html` | the requested channel logo in `https://developer.android.com/reference/android/graphics/Bitmap.html`, or `null` if not available. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/tvprovider/media/tv/ChannelLogoUtils#storeChannelLogo(android.content.Context,long,android.net.Uri)` |   |
| `https://developer.android.com/reference/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
public static boolean storeChannelLogo(
    @NonNull Context context,
    long channelId,
    @NonNull Bitmap logo
)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | the context used to access the system content provider |
| `long channelId` | the ID of the target channel with which the given logo should be associated |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Bitmap.html logo` | the logo image to be stored |

| Returns |
|---|---|
| `boolean` | `true` if successfully stored the logo in the system content provider, otherwise `false`. |

| See also |
|---|---|
| `https://developer.android.com/reference/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)

```
public static boolean storeChannelLogo(
    @NonNull Context context,
    long channelId,
    @NonNull Uri logoUri
)
```

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 `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 (`https://developer.android.com/reference/android/content/ContentResolver.html#SCHEME_CONTENT`)
- android.resource (`https://developer.android.com/reference/android/content/ContentResolver.html`)
- 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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | the context used to access the system content provider |
| `long channelId` | the ID of the target channel with which the fetched logo should be associated |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html logoUri` | the `https://developer.android.com/reference/android/net/Uri.html` of the logo file to be fetched and stored in the system provider |

| Returns |
|---|---|
| `boolean` | `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 |
|---|---|
| `https://developer.android.com/reference/androidx/tvprovider/media/tv/ChannelLogoUtils#loadChannelLogo(android.content.Context,long)` |   |