My Android app has a widget.
While my app process is running, the widget remains in a state corresponding wi开发者_开发问答th the state of the app. When the process is gone, I need to reset the state of the widget.
When the Android OS cleans up your application, there is no notification sent to the code before the process exits.
Any ideas on how I can reset the state of the widget? Also, any way to get notified that your process is about to be GC'd?
You shouldn't tie widget or other UI state to process state, since the user is not directly aware of processes being started and stopped, and the act of a process being killed in the background is generally divorced from what they think they are doing.
精彩评论