Does anyone have experience with receiving notifications in a widget when the widget runs in the background?

I made a simple widget that receives notifications for the AccelerometerAxis sensor. This works fine while running in the foreground.

When the widget is going to the background either by switching to an other app or if the autolock goes off. Then the app is ended by the system after a few minutes.

It doesn't matter what I do in the callback method. Even if I return immediately the app is still cancelled by the OS after a few minutes.

I see no point in having a sensor api in the widgets if they do not work while in the background. That would mean an app can only run untill the autolock goes on (usually 60seconds).

Anyone found a solution for this?