google / glance-experimental-tools

Glance Experimental Tools aims to supplement Jetpack Glance with features that are commonly required by developers but not yet available.
https://developer.android.com/jetpack/androidx/releases/glance
Apache License 2.0
167 stars 12 forks source link

fix(configuration): properly propagate the appWidgetId back to the Launcher #9

Open bmc08gt opened 1 year ago

bmc08gt commented 1 year ago

Allow the appWidgetId to be relayed to the launcher if it is not provided in the configuration activity intent.

This prevents the following error when applyConfiguration is called on at least the Pixel 3 XL running Android 12.

Error: appWidgetId (EXTRA_APPWIDGET_ID) was not returned from the widget configuration activity.
bmc08gt commented 1 year ago

Is this happening after certain steps or can you always reproduce it in the same device?

The only issue I could see here is with activity recreation.

Seem to be able to always recreate this on my Pixel 3 XL. Default launcher with no Intent modification.

marcelpinto commented 1 year ago

Ohhh... I just remember there was an issue in certain Android version that modified the intent and that's why we changed our guidance to always include the widget ID again when setting the result

val resultValue = Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
setResult(Activity.RESULT_CANCELED, resultValue)

https://developer.android.com/develop/ui/views/appwidgets/configuration#update