Homescreen Widget - process dies, widget left in limbo, need recovery strategy

  • Replies:0
norbstar
  • Forum posts: 1

May 20, 2013, 12:32:15 AM via Website

Guys

Hope you can offer me some sage advance.
I assure you it will be most appreciated.

I have a home screen widget backed by a Service and am seeking a guaranteed solution to recover from the death of the process hosting the widget.

The widget seems to die as the result of 'killing proc' or 'process has died'.

I might be missing a trick here and it might be blind to the blatantly obvious. If so please point me in the right direction.

I am currently using the ACTION_SCREEN_ON intent to check the state of the widget when the screen is turned back on. This works, but does not cater for the scenario where the process is killed while the screen is still on.

This leaves my widget in limbo, as the data it depends upon to function has been lost.

Q. Is the OS guaranteed to spawn a new process if the widget is killed?

Q. If so, is there a way to have the 'widget host' post an action when it spawns the
new process?

Q. If not, is there an action I can listen for that will result in a new process being spawned to handle the action?

As I understand it the android.appwidget.action.APPWIDGET_UPDATE action is only delivered on first initialisation of the widget so I can't use
this as a trigger to re-initialise the widget.

I had hoped to use the AlarmManager to implement a heartbeat in order to prompt the widget and provide it with the means to recover had it been killed.

This does not seem to work as the context is lost along with the process.

Any suggestions on a strategy for dealing with such a scenario.

Thanks in advance for your advice.

Reply