Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/src/main/java/com/capyreader/app/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,23 @@ class MainApplication : Application(), SingletonImageLoader.Factory {

/**
* [Docs](https://developer.android.com/develop/ui/compose/glance/generated-previews)
*
* On Android 17 the underlying `setWidgetPreview` binder call throws when the
* receiver isn't a registered AppWidget provider in the current profile (e.g. a
* private/work space), which would otherwise crash the app on launch.
* See https://issuetracker.google.com/issues/488125748
*/
private fun loadWidgetPreview() {
MainScope().launchUI {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
val manager = GlanceAppWidgetManager(applicationContext)
manager.setWidgetPreviews(HeadlinesWidgetReceiver::class)
manager.setWidgetPreviews(SpotlightWidgetReceiver::class)

try {
manager.setWidgetPreviews(HeadlinesWidgetReceiver::class)
manager.setWidgetPreviews(SpotlightWidgetReceiver::class)
} catch (e: IllegalArgumentException) {
CapyLog.error("widget_preview", e)
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/1211.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crash for widgets on Android 17. Thanks for the bug reports here!
Loading