are multiple broadcast receivers legal in android?

2019-04-07 13:30发布

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

2条回答
\"骚年 ilove
2楼-- · 2019-04-07 14:12

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.

查看更多
一夜七次
3楼-- · 2019-04-07 14:15

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.

查看更多
登录 后发表回答