Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

are multiple broadcast receivers legal in android?

Is this true?

Only one BroadcastReceiver class can be specified per application. Should you need to incorporate two or more BroadcastReceivers from different SDKs, you will need to create your own BroadcastReceiver class that will receive all broadcasts and call the appropriate BroadcastReceivers for each type of Broadcast.

http://code.google.com/apis/analytics/docs/mobile/android.html#google-play-tracking

There is no mention of this in the manifest documentation for <receiver/>

http://developer.android.com/guide/topics/manifest/receiver-element.html

like image 481
danb Avatar asked Nov 04 '11 17:11

danb


2 Answers

The Android platform only delivers the install tracking intent to a single "receiver" for your application. What they mean is, if you are using two install trackers for your application you can not put two receivers containing the same action "com.android.vending.INSTALL_REFERRER". If this is the case, then you can add a meta-data tag like

<meta-data android:name="forward.1"  android:value="<other receiver's name>" />

to your receiver so both receivers receive the Intent.

like image 22
siavach Avatar answered Sep 19 '22 21:09

siavach


The quoted passage is from the documentation for Google's mobile analytics package. It may be that Google's mobile analytics package cannot support more than one BroadcastReceiver for Google's mobile analytics package's broadcasts.

Android itself can most certainly have more than one BroadcastReceiver per application.

like image 142
CommonsWare Avatar answered Sep 20 '22 21:09

CommonsWare