7

I have written an install receiver to determine when an app has been installed via the Market. However, I also want to pass the INSTALL_REFERRER broadcast onto other receivers such as the Google Analytics AnalyticsReceiver if it is installed within the app. Importantly, I do NOT know if other receivers are installed as my receiver will be used by other developers within their apps.

Currently, I receive the broadcast and when complete I call:

AnalyticsReceiver receiver = new AnalyticsReceiver();

receiver.onReceive(context, intent);

The issue is the AnalyticsReceiver class may not be present.

So how do I pass on the broadcast if I'm not sure whether the app uses the AnalyticsReceiver?

Or will Android itself make sure each receiver installed gets the broadcast?

Many thanks!

Yahel
  • 35,856
  • 22
  • 98
  • 150
user605333
  • 303
  • 1
  • 4
  • 9
  • 1
    After more research I am fairly sure you cannot have more than one install receiver, so any tips on how you "pass on" the install broadcast would be great! – user605333 Feb 13 '11 at 17:51

2 Answers2

5

This doesn't really answer the question, but the only intended destination for INSTALL_REFERRER is the Google Analytics library, and thus there are zero guarantees about the data contained in the broadcast (or anything about the broadcast for that matter), so you shouldn't rely on it.

On a side note, here are some related S.O. questions:

Community
  • 1
  • 1
Roman Nurik
  • 29,417
  • 7
  • 81
  • 82
2

Roman's answer is not entirely correct. They don't go into step by step instructions, but Google themselves recommend using your own broadcast receiver if you need to. I do think they added this blurb recently, but not sure when. I'm pretty positive it did not exist when I answered one of the questions he links.

From their guide:

Note: 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.

This also seems to answer the question of whether you can blindly re-broadcast, at least according to Google.

DougW
  • 25,384
  • 18
  • 76
  • 106