Android Widget Lifecycle

后端 未结 1 1646
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 01:45

In my widget class that extends extends AppWidgetProvider I have some static final ArrayLists that contain data. I have some buttons in my Widget that when pressed result in

相关标签:
1条回答
  • 2021-01-12 02:07

    Is the ArrayList safe to use in this context?

    No. If nothing else of your application is running, your process may be terminated between onUpdate() calls.

    Is there any widget lifecycle events that would cause the list to be re instantiated.

    Your process was terminated.

    I am finding it very hard to find any documentation on Widget Lifecycle events.

    That's because there is no lifecycle in the manner that you are thinking.

    An AppWidgetProvider is a manifest-registered BroadcastReceiver. A manifest-registered BroadcastReceiver lives only so long as does its onReceive() call. Nothing that lives outside of that scope, such as static data members, will be reliable.

    Please store your information in files or databases.

    0 讨论(0)
提交回复
热议问题