GlanceAppWidgetReceiver

abstract class GlanceAppWidgetReceiver : AppWidgetProvider


AppWidgetProvider using the given GlanceAppWidget to generate the remote views when needed.

This should typically used as:

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

Note: If you override any of the AppWidgetProvider 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 AppWidgetProvider.goAsync, as it will be called by the super implementation. This means your processing time must be short.

Summary

Constants

const String

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

Public constructors

Public functions

open Unit
@CallSuper
onAppWidgetOptionsChanged(
    context: Context,
    appWidgetManager: AppWidgetManager,
    appWidgetId: Int,
    newOptions: Bundle
)
open Unit
@CallSuper
onDeleted(context: Context, appWidgetIds: IntArray)
open Unit
onReceive(context: Context, intent: Intent)
open Unit
@CallSuper
onUpdate(
    context: Context,
    appWidgetManager: AppWidgetManager,
    appWidgetIds: IntArray
)

Public properties

open CoroutineContext

Override coroutineContext to provide custom CoroutineContext in which to run update requests.

abstract GlanceAppWidget

Instance of the GlanceAppWidget to use to generate the App Widget and send it to the AppWidgetManager

Constants

ACTION_DEBUG_UPDATE

const val ACTION_DEBUG_UPDATEString

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
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
@ExperimentalGlanceApi
open val coroutineContextCoroutineContext

Override coroutineContext to provide custom CoroutineContext in which to run update requests.

Note: This does not set the CoroutineContext for the GlanceAppWidget, which will always run on the main thread.

glanceAppWidget

Added in 1.0.0
abstract val glanceAppWidgetGlanceAppWidget

Instance of the GlanceAppWidget to use to generate the App Widget and send it to the AppWidgetManager