Search code examples
androidbroadcastreceiveralarmmanagerbackground-service

Background app without Gui, starts periodically every hour Android


I am making an application which will check for files on storage directory and then utilize the files and upload to ssh server.

I was thinking about making a BroadcastReceiver which will start background Service on system boot, the Service will update AlarmManager which will start every hour/every day a class for utilize/upload file.

Can you give me advice if my logic is ok, or how can I improve it ?

Thanks.


Solution

  • This is why Google created the SyncAdapter.

    You should look at the SyncAdapter example on the Android developers site. Sync Adapters

    There are a lot of moving parts; along with SyncAdapter you'll need to learn about Authenticator and ContentProvider (if you are dealing with the file system you can skip ContentProvider). This is the framework Google provides for asynchronously moving data to/from servers. You have the option to use a BroadcastReceiver if you want, but there are a couple other methods for scheduling data syncs.