Arslan Anwar
Arslan Anwar

Reputation: 18746

Broadcast receiver when application is off android

I am going to implement Download Queue for my application. One of its feature will be when Network get connected or disconnected. I want to notify my QueueManger(Service) to update items status and stop. I know use of Broadcast Receiver and how to use it. My question is if my application is stooped (finished) will broadcast receiver will work? Will it notify application or not?

If not is there any way to achieve this functionality even when application is stooped.

Upvotes: 0

Views: 685

Answers (2)

Kevin Grant
Kevin Grant

Reputation: 2351

If you register your receiver in the XML instead of programmatically, then it should be able to catch these even when the program is not running.

See question, same solution applies Intent action for network events in android sdk

Upvotes: 3

waqaslam
waqaslam

Reputation: 68167

If you have defined your broadcast receiver as <receiver> in AndroidManifest.xml and listening for android's default action strings, then Yes, it will work.

Otherwise, I would recommend you to make use of Service. It can run silently in the background and do all the logic you want. Your service can even be provoked automatically when the phone is restarted (if you code correctly).

Upvotes: 2

Related Questions