0

I am currently working on a Xamarin android app. What it does is grabs data from a website, parses it, and populates a SQLite database. This is all on button click though. What I would like to do is get rid of the button and have this run once a month as a background service.

I have already viewed the link below for creating them and looked at multiple other stackoverflow posts. https://developer.xamarin.com/guides/android/application_fundamentals/services/creating-a-service/

If someone could provide me an example of how this can be done it would be really appreciated. For this type of service I am thinking it would be best to use Started Services? If that is the correct way to go then how would I make sure the service would start and stop once a month. Or would the service continue to run but a method only be called once a month?

Edit: Okay so I finally found a basic structure for creating a Started Service in the link below. https://xamarinhelp.com/xamarin-background-tasks/

So the next step would be to figure out how to run the code within the StartCommandResult method only once a month. AlarmManager may seem to be the way to go?

Edit 2: So i have found the below link regarding AlarmManager, but for a week. Repeat Alarm once in a week in android

Now I would need to figure out how many days are in the current month and pass that into the setrepeating()?

Freiza1991
  • 71
  • 1
  • 2
  • 9
  • have you checked Akavache? you can display offline data instantly and at the same time update your offline local data from the web. Performance is also benefit over sqlite. I started with sqlite and now removed from my app and use only akavache. – Emil Jul 18 '17 at 14:40
  • @batmaci I have heard if Akavache, but never researched it. Not to be rude, but I am unsure of how this would help with my question though. The SQLite I am currently not having an issue. The issue is figuring out how to run a service even when the app is closed once a month to parse data from an html page and insert it into the database. Unless Akavache helps with that purpose? – Freiza1991 Jul 18 '17 at 14:45
  • ok it wont help when it is closed. it only does things on the background while using your cached data without any performance decrease. but you need to be on the app of course. I have heard about signalR also works for xamarin but I am unsure if it helps you. you may google it – Emil Jul 18 '17 at 14:51
  • @batmaci I will take a look into that. Thanks for the tips and new information. – Freiza1991 Jul 18 '17 at 15:04

0 Answers0