Skip to content

Conversation

@bmc08gt
Copy link

@bmc08gt bmc08gt commented Feb 27, 2023

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.

Allow the appWidgetId to be relayed to the launcher if it is not provided in the configuration activity intent.
@marcelpinto marcelpinto self-requested a review March 14, 2023 09:39
Copy link
Contributor

@marcelpinto marcelpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bmc08gt
Copy link
Author

bmc08gt commented Mar 16, 2023

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
Copy link
Contributor

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

Copy link
Contributor

@marcelpinto marcelpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you follow https://developer.android.com/develop/ui/views/appwidgets/configuration#update and:

  1. Create a new intent instead of reusing the activity one when setting the cancel result
  2. Pass the Intent instead of the widget ID and change the result on apply instead.

@bmc08gt bmc08gt requested a review from marcelpinto March 16, 2023 19:42
@bmc08gt bmc08gt changed the title fix(configuration): properly apply the appWidgetId fix(configuration): properly propagate the appWidgetId back to the Launcher Mar 16, 2023
Copy link
Contributor

@marcelpinto marcelpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the change, but could you fix the remaining issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants