Stay organized with collections
Save and categorize content based on your preferences.
Top-level functions summary
suspend T |
Retrieve the state of an app widget.
|
suspend Unit |
Update the state of an app widget using the global PreferencesGlanceStateDefinition.
|
suspend T |
Update the state of an app widget.
|
Extension functions summary
suspend T |
Get the state of an App Widget.
|
Top-level functions
Extension functions
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-05-15 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-15 UTC."],[],[],null,["# androidx.glance.appwidget.state\n===============================\n\nTop-level functions summary\n---------------------------\n\n|-----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `suspend T` | `\u003cT : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?\u003e `[getAppWidgetState](/reference/kotlin/androidx/glance/appwidget/state/package-summary#getAppWidgetState(android.content.Context,androidx.glance.state.GlanceStateDefinition,androidx.glance.GlanceId))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` definition: `[GlanceStateDefinition](/reference/kotlin/androidx/glance/state/GlanceStateDefinition)`\u003cT\u003e,` ` glanceId: `[GlanceId](/reference/kotlin/androidx/glance/GlanceId) `)` Retrieve the state of an app widget. |\n| `suspend `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [updateAppWidgetState](/reference/kotlin/androidx/glance/appwidget/state/package-summary#updateAppWidgetState(android.content.Context,androidx.glance.GlanceId,kotlin.coroutines.SuspendFunction1))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` glanceId: `[GlanceId](/reference/kotlin/androidx/glance/GlanceId)`,` ` updateState: suspend (`[MutablePreferences](/reference/kotlin/androidx/datastore/preferences/core/MutablePreferences)`) `-\u003e` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) `)` Update the state of an app widget using the global PreferencesGlanceStateDefinition. |\n| `suspend T` | `\u003cT : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?\u003e `[updateAppWidgetState](/reference/kotlin/androidx/glance/appwidget/state/package-summary#updateAppWidgetState(android.content.Context,androidx.glance.state.GlanceStateDefinition,androidx.glance.GlanceId,kotlin.coroutines.SuspendFunction1))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` definition: `[GlanceStateDefinition](/reference/kotlin/androidx/glance/state/GlanceStateDefinition)`\u003cT\u003e,` ` glanceId: `[GlanceId](/reference/kotlin/androidx/glance/GlanceId)`,` ` updateState: suspend (T) `-\u003e` T` `)` Update the state of an app widget. |\n\nExtension functions summary\n---------------------------\n\n|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `suspend T` | `\u003cT : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?\u003e `[GlanceAppWidget](/reference/kotlin/androidx/glance/appwidget/GlanceAppWidget)`.`[getAppWidgetState](/reference/kotlin/androidx/glance/appwidget/state/package-summary#(androidx.glance.appwidget.GlanceAppWidget).getAppWidgetState(android.content.Context,androidx.glance.GlanceId))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` glanceId: `[GlanceId](/reference/kotlin/androidx/glance/GlanceId) `)` Get the state of an App Widget. |\n\nTop-level functions\n-------------------\n\n### getAppWidgetState\n\nArtifact: [androidx.glance:glance-appwidget](/jetpack/androidx/releases/glance) \n[View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/state/GlanceAppWidgetState.kt+function:getAppWidgetState) \n\n```\nsuspend fun \u003cT : Any?\u003e getAppWidgetState(\n context: Context,\n definition: GlanceStateDefinition\u003cT\u003e,\n glanceId: GlanceId\n): T\n```\n\nRetrieve the state of an app widget.\n\nThe state definition must be the one used for that particular app widget. \n\n### updateAppWidgetState\n\nArtifact: [androidx.glance:glance-appwidget](/jetpack/androidx/releases/glance) \n[View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/state/GlanceAppWidgetState.kt+function:updateAppWidgetState) \nAdded in [1.0.0](/jetpack/androidx/releases/glance#1.0.0) \n\n```\nsuspend fun updateAppWidgetState(\n context: Context,\n glanceId: GlanceId,\n updateState: suspend (MutablePreferences) -\u003e Unit\n): Unit\n```\n\nUpdate the state of an app widget using the global PreferencesGlanceStateDefinition.\n\nThe state definition must be the one used for that particular app widget. \n\n### updateAppWidgetState\n\nArtifact: [androidx.glance:glance-appwidget](/jetpack/androidx/releases/glance) \n[View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/state/GlanceAppWidgetState.kt+function:updateAppWidgetState) \n\n```\nsuspend fun \u003cT : Any?\u003e updateAppWidgetState(\n context: Context,\n definition: GlanceStateDefinition\u003cT\u003e,\n glanceId: GlanceId,\n updateState: suspend (T) -\u003e T\n): T\n```\n\nUpdate the state of an app widget.\n\nThe state definition must be the one used for that particular app widget.\n\nExtension functions\n-------------------\n\n### getAppWidgetState\n\nArtifact: [androidx.glance:glance-appwidget](/jetpack/androidx/releases/glance) \n[View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/state/GlanceAppWidgetState.kt+function:getAppWidgetState) \n\n```\nsuspend fun \u003cT : Any?\u003e GlanceAppWidget.getAppWidgetState(\n context: Context,\n glanceId: GlanceId\n): T\n```\n\nGet the state of an App Widget."]]