efox29
efox29

Reputation: 141

Android - What do i need to perform a service in the background

I currently have a service setup that emails a bunch of files. What I want to do is add a scheduling system setup so that at a certain time each night, that service runs (those emails are sent).

I thought maybe a Broadcast Receiver triggered by an AlarmManager would work, and it does except it only runs when the app is running. I read that Broadcast Receivers only run in the UI thread. I need this to work regardless if the app is running or not.

Im going to assume that what I need is a broadcast receiver to start [blank] to run in the background and when the AlarmManager sends an alarm that [blank] will start the service I already have setup.

If that is the correct procedure, what is [blank] ? If its not the correct procedure then what is ?

Thanks

Upvotes: 0

Views: 245

Answers (2)

summer
summer

Reputation: 136

Your procedure is correct,if you don't need an IPC ,then no necessary to implement a remote service.

Upvotes: 0

James Black
James Black

Reputation: 41858

You may want to run a RemoteService (http://saigeethamn.blogspot.com/2009/09/android-developer-tutorial-part-9.html), and this article explains how to use the AlarmManager to start up a Service.

http://android-er.blogspot.com/2010/10/simple-example-of-alarm-service-using.html

I actually made this change today, and my program is working better at work.

The RemoteService is so that the Service doesn't die when your Activity dies, basically.

Upvotes: 1

Related Questions