Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intercept INSTALL_REFERRER and then forward on to Google AnalyticsReceiver

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!

like image 519
user605333 Avatar asked Feb 13 '11 12:02

user605333


2 Answers

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:

  • Get Android Google Analytics referrer tag
  • Get referrer after installing app from Android Market
like image 110
Roman Nurik Avatar answered Nov 05 '22 12:11

Roman Nurik


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.

like image 20
DougW Avatar answered Nov 05 '22 10:11

DougW