Run a task on android every specific interval of time

chahidchahid LBMember ✭✭
edited October 16 in Xamarin.Android

Hello everyone,
I am working on an android app with local sqlite database on my phone. I have an upload button in my ativity that upload the data to a server.
I need to make the upload mechanism automatic let's say every 30 min run the upload procedure even if the app is closed.
Any Idea how to do this.
If I have to create a service which one do I use? startservice or bounded services or intent service ?

Answers

  • RyanFrenchRyanFrench USMember ✭✭

    Research AbstractThreadedSyncAdapter. This is built into Android. In my setup I have a foreground service that always runs in the background keeping the app alive (uploading, location logging, geofencing). Apart from that service I also have a sync service, a stub provider, a stub authenticator, and a sync adapter.

    When the adapters OnPerformSync() method is executed I launch the upload onto a new thread to handle the work.

    If you need help with this PM me and I can give you specifics.

  • chahidchahid LBMember ✭✭

    @RyanFrench thank you for your reply. Can you give a simple example how to implement this?

Sign In or Register to comment.