# GlanceAppWidgetReceiver

Artifact: [androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance) [View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/GlanceAppWidgetReceiver.kt+class:androidx.glance.appwidget.GlanceAppWidgetReceiver) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/glance#1.0.0)

<br />

```
abstract class GlanceAppWidgetReceiver : AppWidgetProvider
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) |||
|   | ↳ | [android.appwidget.AppWidgetProvider](https://developer.android.com/reference/android/appwidget/AppWidgetProvider.html) ||
|   |   | ↳ | [androidx.glance.appwidget.GlanceAppWidgetReceiver](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver) |

*** ** * ** ***

`https://developer.android.com/reference/android/appwidget/AppWidgetProvider.html` using the given `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidget` to generate the remote views when needed.

This should typically used as:

```kotlin
class MyGlanceAppWidgetProvider : GlanceAppWidgetProvider() {
  override val glanceAppWidget: GlanceAppWidget()
    get() = MyGlanceAppWidget()
}
```

Note: If you override any of the `https://developer.android.com/reference/android/appwidget/AppWidgetProvider.html` methods, ensure you call their super-class implementation.

Important: if you override any of the methods of this class, you must call the super implementation, and you must not call `https://developer.android.com/reference/android/content/BroadcastReceiver.html#goAsync()`, as it will be called by the super implementation. This means your processing time must be short.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#ACTION_DEBUG_UPDATE()` Action for a broadcast intent that will try to update all instances of a Glance App Widget for debugging. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#GlanceAppWidgetReceiver()()` |

| ### Public functions |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#onAppWidgetOptionsChanged(android.content.Context,android.appwidget.AppWidgetManager,kotlin.Int,android.os.Bundle)( context: https://developer.android.com/reference/android/content/Context.html, appWidgetManager: https://developer.android.com/reference/android/appwidget/AppWidgetManager.html, appWidgetId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, newOptions: https://developer.android.com/reference/android/os/Bundle.html )` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#onDeleted(android.content.Context,kotlin.IntArray)(context: https://developer.android.com/reference/android/content/Context.html, appWidgetIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#onReceive(android.content.Context,android.content.Intent)(context: https://developer.android.com/reference/android/content/Context.html, intent: https://developer.android.com/reference/android/content/Intent.html)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#onUpdate(android.content.Context,android.appwidget.AppWidgetManager,kotlin.IntArray)( context: https://developer.android.com/reference/android/content/Context.html, appWidgetManager: https://developer.android.com/reference/android/appwidget/AppWidgetManager.html, appWidgetIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html )` |

| ### Public properties |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` | `@https://developer.android.com/reference/kotlin/androidx/glance/ExperimentalGlanceApi https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#coroutineContext()` Override `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#coroutineContext()` to provide custom `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` in which to run update requests. |
| `abstract https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidget` | `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#glanceAppWidget()` Instance of the `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidget` to use to generate the App Widget and send it to the `https://developer.android.com/reference/android/appwidget/AppWidgetManager.html` |

### Inherited functions

From [android.appwidget.AppWidgetProvider](https://developer.android.com/reference/android/appwidget/AppWidgetProvider.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/appwidget/AppWidgetProvider.html#onDisabled(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/appwidget/AppWidgetProvider.html#onEnabled(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/appwidget/AppWidgetProvider.html#onRestored(android.content.Context, int[], int[])(

context: https://developer.android.com/reference/android/content/Context.html,

oldWidgetIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html,

newWidgetIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html

)` From [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#abortBroadcast()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#clearAbortBroadcast()()` `https://developer.android.com/reference/android/os/Bundle.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#getResultExtras(boolean)(makeMap: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://developer.android.com/reference/android/content/BroadcastReceiver.PendingResult.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#goAsync()()` `https://developer.android.com/reference/android/os/IBinder.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#peekService(android.content.Context, android.content.Intent)(myContext: https://developer.android.com/reference/android/content/Context.html, service: https://developer.android.com/reference/android/content/Intent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#setOrderedHint(boolean)(isOrdered: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResult(int, java.lang.String, android.os.Bundle)(code: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, extras: https://developer.android.com/reference/android/os/Bundle.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResultExtras(android.os.Bundle)(extras: https://developer.android.com/reference/android/os/Bundle.html)`

### Inherited properties

From [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#abortBroadcast` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#debugUnregister` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#isInitialStickyBroadcast` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#isOrderedBroadcast` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#resultCode` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#resultData` `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#sentFromPackage` `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#sentFromUid`

## Constants

### ACTION_DEBUG_UPDATE

```
const val ACTION_DEBUG_UPDATE: String
```

Action for a broadcast intent that will try to update all instances of a Glance App Widget for debugging.

```
adb shell am broadcast -a androidx.glance.appwidget.action.DEBUG_UPDATE -n APP/COMPONENT
```

where APP/COMPONENT is the manifest component for the GlanceAppWidgetReceiver subclass. This only works if the Receiver is exported (or the target device has adb running as root), and has androidx.glance.appwidget.DEBUG_UPDATE in its intent-filter. This should only be done for debug builds and disabled for release.

## Public constructors

### GlanceAppWidgetReceiver

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

```
GlanceAppWidgetReceiver()
```

## Public functions

### onAppWidgetOptionsChanged

```
@CallSuper
open fun onAppWidgetOptionsChanged(
    context: Context,
    appWidgetManager: AppWidgetManager,
    appWidgetId: Int,
    newOptions: Bundle
): Unit
```

### onDeleted

```
@CallSuper
open fun onDeleted(context: Context, appWidgetIds: IntArray): Unit
```

### onReceive

```
open fun onReceive(context: Context, intent: Intent): Unit
```

### onUpdate

```
@CallSuper
open fun onUpdate(
    context: Context,
    appWidgetManager: AppWidgetManager,
    appWidgetIds: IntArray
): Unit
```

## Public properties

### coroutineContext

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

```
@ExperimentalGlanceApi
open val coroutineContext: CoroutineContext
```

Override `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidgetReceiver#coroutineContext()` to provide custom `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` in which to run update requests.

Note: This does not set the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` for the GlanceAppWidget, which will always run on the main thread.

### glanceAppWidget

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

```
abstract val glanceAppWidget: GlanceAppWidget
```

Instance of the `https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidget` to use to generate the App Widget and send it to the `https://developer.android.com/reference/android/appwidget/AppWidgetManager.html`