Can we create a widget in jetpack glance and updat...
# compose
f
Can we create a widget in jetpack glance and update it frequently based on the events from socket or MQTT.
🚫 1
m
The "update it... from socket or MQTT" is unrelated to Glance or Compose. Whether you use Glance or hand-assemble your own
RemoteViews
for your app widget does not matter. Frequent network updates is very bad for battery life, so Google (in Android) and manufacturers (in devices) go to great lengths to prevent developers from doing this. If you need help with that subject, I recommend Stack Overflow.
f
Ok I understand due to battery usage constraints it is not recommended. But is it achievable or there is uncertainity that system will terminate such process automatically based on memory usage.
In My Testing Env i have Simulated Socket events via Count-DownTimer created in Coroutine. I am starting my timer in onUpdate() of GlanceWidgetBroadcast and updating UI through it every second. It works but when Device is on low memory or idle for long time it stops updating the widget? Any idea why it happens?
z
Android has always killed processes that are in the background when a device is low on memory. Some devices will kill processes even more aggressively (eg as soon as they’re backgrounded). As Mark said, this sort of thing is strongly discouraged, and the operating system will sometimes enforce that by killing misbehaving apps.
I would strongly suggest using proper push notifications
âž• 2