xamarin / AndroidSupportComponents

Xamarin bindings for Android Support libraries - For AndroidX see https://github.com/xamarin/AndroidX
MIT License
146 stars 56 forks source link

PeriodicWorkRequest not running as expected #200

Open jrahma opened 5 years ago

jrahma commented 5 years ago

Hi,

In the attached sample, I have created a PeriodicWorkRequest to be running every 30 minutes

I have logged the DoWork in my AppCenter Analytics and I am getting the DoWork when I start the app but not every 30 minutes. For example, today I started the app and I got the DoWork logged but after that and until now (more than 2 hours) nothing is logged.

AppCenter

LocalNotifications.zip

Thanks, Jassim

ndastur commented 5 years ago

This is a function of the Android operating system. The time you specify is a minimum. The OS decides when to exec your task. All part of better battery management etc.

jrahma commented 5 years ago

@ndastur How?!

it's called background worker which means it should run in the background not just when I open the app

ndastur commented 5 years ago

@jrahma just trying to be helpful. It does work in the background. Read the Android documentation and you'll get a better understanding of how Android does background work now. It might help to post some of your sample code. Without that, we don't know how you have implemented the Worker. I can let you know that I have successfully set up periodic tasks in Xamarin and it works as expected.

jrahma commented 5 years ago

@ndastur sample was already attached in my issue