Fixed
Status Update
Comments
na...@gmail.com <na...@gmail.com> #2
How about using GlanceAppWidgetManager#getGlanceIds?
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 4376d1fb26e56e64884414b1017dbd1501f30119
Author: marcelpinto <marcelpinto@google.com>
Date: Tue Jun 28 20:06:17 2022
New method getGlanceIdBy id or intent
There is currently no way to get a GlanceId from
an existing appWidgetId (Int) or from the configuration activity intent.
In some cases this might be needed to migrate existing widgets.
Bug: 230391946
Test: ./gradlew :glance:glance-appwidget:connectedAndroidTest
Relnote: "New method to get GlanceId from an existing appWidgetId or an intent from a configuration activity"
Change-Id: Icb70ca815f0858d0002c860a1446301f6a138db1
M glance/glance-appwidget/api/public_plus_experimental_current.txt
M glance/glance-appwidget/src/androidAndroidTest/kotlin/androidx/glance/appwidget/GlanceAppWidgetManagerTest.kt
M glance/glance-appwidget/src/androidMain/kotlin/androidx/glance/appwidget/GlanceAppWidgetManager.kt
M glance/glance-appwidget/api/current.txt
M glance/glance-appwidget/api/restricted_current.txt
https://android-review.googlesource.com/2138301
Branch: androidx-main
commit 4376d1fb26e56e64884414b1017dbd1501f30119
Author: marcelpinto <marcelpinto@google.com>
Date: Tue Jun 28 20:06:17 2022
New method getGlanceIdBy id or intent
There is currently no way to get a GlanceId from
an existing appWidgetId (Int) or from the configuration activity intent.
In some cases this might be needed to migrate existing widgets.
Bug: 230391946
Test: ./gradlew :glance:glance-appwidget:connectedAndroidTest
Relnote: "New method to get GlanceId from an existing appWidgetId or an intent from a configuration activity"
Change-Id: Icb70ca815f0858d0002c860a1446301f6a138db1
M glance/glance-appwidget/api/public_plus_experimental_current.txt
M glance/glance-appwidget/src/androidAndroidTest/kotlin/androidx/glance/appwidget/GlanceAppWidgetManagerTest.kt
M glance/glance-appwidget/src/androidMain/kotlin/androidx/glance/appwidget/GlanceAppWidgetManager.kt
M glance/glance-appwidget/api/current.txt
M glance/glance-appwidget/api/restricted_current.txt
Description
Version used:glance:1.0.0-alpha03
Devices/Android versions reproduced on:
I want to update specific widget after GlanceAppWidgetReceiver#onReceive.
But I can't create AppWidgetId because its internal.
But GlanceAppWidget#update needs GlanceId(AppWidgetId).
Please make AppWidgetId public, or make some create method from appWidgetId(Int) like createGranceId(Int).
Or is there some solution?
I want to make a widget that like displays the weather at one point.
Users can put multiple different widgets.(different point of weather)
The point data saved in Room(database).
1. Call GlanceAppWidgetReceiver#onReceive, intent has extra like "targetWidgetId" : 1.
2. Launch WorkManager to fetch weather data.(Pass the widget id to workmanager)
3. WorkManager fetch weather data by using widgetId.(select weather id from Room by using widget id)
4. WorkManager launch broadcast with weather data and targetWidegetId.
5. Called GlanceAppWidgetReceiver#onReceive, then only update widget that widgetId is 1.
There are multiple widgets like widgetId 1,2,3 and they have different point of weather.
I want to update specific widget by using widget id.