Dennis
Dennis

Reputation: 2311

Should I use BroadcastReceiver or Service?

I don't clearly understand the difference between them. I tried to read about it and found that Services are for long-running operations but nobody said what about short-running operations.

I want to do something at midnight - just update some things. I've made an AlarmManager for midnight but I don't know if I should call a BroadcastReceiver or a Service.

What should I do?

Upvotes: 0

Views: 322

Answers (2)

stinepike
stinepike

Reputation: 54732

I will personally suggest you to use BroadcastReceiver in that case. Because by using the broadcast receiver your application can only be trigerred when the alam goes on. On the other side if you use service then your service will run in background continueously.

Upvotes: 0

ninehundreds
ninehundreds

Reputation: 1105

It sounds like you will be performing a minimal amount of processing based on what little you have mentioned. In that case a service may be overkill. There are good discussions covering the differences between broadcast receivers and services. Check out the API docs or have a look here:

Android Broadcast Receiver vs Service

Upvotes: 1

Related Questions