Skip to content

widget configs fail to persist #23

@wassupluke

Description

@wassupluke

Widget configurations do not persist across app "force stop" events.

May need to use SharedPreferences to save which appWidgetId is supposed to be "Weather" vs "Alarm".

The potential fix in onUpdate or onReceive:

val prefs = context.getSharedPreferences("WidgetPrefs", Context.MODE_PRIVATE)
val type = prefs.getString("type_$appWidgetId", "unknown")

when (type) {
    "weather" -> updateWeatherWidget(appWidgetId)
    "alarm" -> updateAlarmWidget(appWidgetId)
    else -> { /* Log an error or show a 'Setup' view, don't just guess! */ }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions