2

I understand the basic difference between the two types of intent registering. But i want to know is there any difference in terms of speed??

Reddy
  • 79
  • 1
  • 8

2 Answers2

0

Registering broadcast from code and through manifest doesn't have much difference except these points mentioned in the documentation:

1)When you use registerReceiver(BroadcastReceiver, IntentFilter), any application may send broadcasts to that registered receiver. You can control who can send broadcasts to it through permissions described below.

2)When you publish a receiver in your application's manifest and specify intent-filters for it, any other application can send broadcasts to it regardless of the filters you specify. To prevent others from sending to it, make it unavailable to them with android:exported="false".

Read more in developer documentations: http://developer.android.com/reference/android/content/BroadcastReceiver.html You can use them based on your requirement.

Saurav
  • 560
  • 4
  • 17
0

The BroadcastReceiver class (when launched as a component through a manifest's tag) is an important part of an application's overall lifecycle.

If you registerRecevier in onResume method in activity and unregisterReceiver in onPause() method. Your receiver life time is this activity life time.

msevgi
  • 4,828
  • 2
  • 24
  • 30