Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BroadcastReceiver lifecycle

1) I have an Activity. This Activity starts a service, which in turn creates and registers a BroadcastReceiver.

2) I have an Activity. This Activity creates and registers a BroadcastReceiver.

When does BroadcastReceiver's life end in each of the above cases? In other words - when it gets destroyed and won't listen to broadcasts anymore?

like image 387
rincEwind Avatar asked Jan 05 '14 16:01

rincEwind


2 Answers

Declare broadcast receiver in manifest to achieve independent life cycle for it.

http://developer.android.com/reference/android/content/BroadcastReceiver.html

like image 194
AndRSoid Avatar answered Nov 10 '22 01:11

AndRSoid


Only onReceive() method is called in BroadcastReciver's life cycle.

like image 26
Ajay Vishwakarma Avatar answered Nov 10 '22 01:11

Ajay Vishwakarma