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! */ }
}
Widget configurations do not persist across app "force stop" events.
May need to use
SharedPreferencesto save whichappWidgetIdis supposed to be "Weather" vs "Alarm".The potential fix in
onUpdateoronReceive: