'How to identify multiple instances of Glance App Widget
I am trying to create a widget which shows information about a hardware device.
There can be multiple of these devices and user will be able to add same widget for different devices.
I am looking for a way to understand which device information should be shown inside GlanceAppWidget.Content()
method. In Classical Android Widgets it was possible by checking appWidgetId passed to update()
method. At Glance appWidgetId is hidden intentionally but I could not find an alternative solution.
Any suggestions?
Solution 1:[1]
Probably you will use a configuration activity when the widget is placed to select the device right?
You can then use the GlanceID to store data in the state of that specific instance (updateAppWidgetState())
. Then inside the Content you can retrieve the currentState
to know which hardware device needs to be shown.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Marcel |