MultiProcessGlanceAppWidget

abstract class MultiProcessGlanceAppWidget : GlanceAppWidget


MultiProcessGlanceAppWidget can be used with androidx.glance.appwidget.GlanceAppWidgetReceiver to support multiprocess use cases where different widget receivers run in different processes. Note that the worker must still run in the same process as the receiver.

Summary

Public constructors

Public functions

open MultiProcessConfig?

Override getMultiProcessConfig to provide a androidx.work.multiprocess.RemoteWorkerService that runs in the same process as the androidx.glance.appwidget.GlanceAppWidgetReceiver that this is attached to.

Inherited functions

From androidx.glance.appwidget.GlanceAppWidget
open Unit
onCompositionError(
    context: Context,
    glanceId: GlanceId,
    appWidgetId: Int,
    throwable: Throwable
)

A callback invoked when the AppWidgetSession encounters an exception.

open suspend Unit
onDelete(context: Context, glanceId: GlanceId)

Method called by the framework when an App Widget has been removed from its host.

abstract suspend Unit
provideGlance(context: Context, id: GlanceId)

Override this function to provide the Glance Composable.

open suspend Unit
providePreview(context: Context, widgetCategory: Int)

Override this function to provide a Glance Composable that will be used when running this widget in preview mode.

suspend Unit
update(context: Context, id: GlanceId)

Run the composition in provideGlance and send the result to AppWidgetManager.

Inherited properties

From androidx.glance.appwidget.GlanceAppWidget
open PreviewSizeMode

Defines handling of sizes for previews.

open SizeMode

Defines the handling of sizes.

open GlanceStateDefinition<*>?

Data store for widget data specific to the view.

Public constructors

MultiProcessGlanceAppWidget

Added in 1.2.0-alpha01
MultiProcessGlanceAppWidget(
    errorUiLayout: @LayoutRes Int = R.layout.glance_error_layout
)

Public functions

getMultiProcessConfig

Added in 1.2.0-alpha01
open fun getMultiProcessConfig(context: Context): MultiProcessConfig?

Override getMultiProcessConfig to provide a androidx.work.multiprocess.RemoteWorkerService that runs in the same process as the androidx.glance.appwidget.GlanceAppWidgetReceiver that this is attached to.

If null, then this widget will be run with normal WorkManager, i.e. the same behavior as GlanceAppWidget.

If running in a non-default process, you should also declare a subclass of androidx.glance.appwidget.MyPackageReplacedReceiver in AndroidManifest.xml for that process, in order to handle android.content.Intent.ACTION_MY_PACKAGE_REPLACED broadcasts.