Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.android.vending.INSTALL_REFERRER isn't working

I originally asked this question, about passing parameters through a market link into my app on install.

Everyone seems to be saying to create a BroadcastListener with the intent-filter action of com.android.vending.INSTALL_REFERRER. All the documentation on that seems to imply this is a capability of Google Analytics (the documentation is in v1, but I can only download v2 SDK at this point... so that's what I am using). I can't get these links to pass data through. I have my full manifest and my broadcast listener. I have included Google Analytics just in case that was a requirement.

  • Google Analytics Reference
  • Generated link to market from here
  • Link to my app in the store
  • Link with parameters in the store

It doesn't work at all. My broadcast listener is never called, nothing gets printed out in the logs. Help!

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.robotsidekick.webbrowser"
      android:versionCode="4"
      android:versionName="4.0">

<uses-sdk android:minSdkVersion="17"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:label="@string/app_name"
    android:icon="@drawable/ic_launcher">

    <activity
        android:name="WebBrowser"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <receiver
        android:exported="true"
        android:name="com.robotsidekick.webbrowser.InstallReceiver">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>

</application>

</manifest>

Broadcast Listener

public class InstallReceiver extends BroadcastReceiver
{
    private static final String TAG = "InstallReceiver";

    public void onReceive(Context context, Intent intent)
    {
        Log.e(TAG, "Context: " + context);
        Bundle extras = intent.getExtras();
        if (extras != null)
        {
            Log.e(TAG, "Extras:");
            for (String keys : extras.keySet())
            {
                Log.e(TAG, keys + " -> " + extras.get(keys));
            }
        }
        else
        {
            Log.e(TAG, "Extras are null");
        }
    }
}
like image 773
xbakesx Avatar asked Feb 13 '13 22:02

xbakesx


1 Answers

So xbakesx says that it seems to work if his receiver extends com.google.analytics.tracking.android.AnalyticsReceiver.

I think the key is that the intent has permissions for ...AnalyticsReceiver and so no other class that is not extending it can pick up the intent. If you look at their test broadcast https://developers.google.com/analytics/solutions/testing-play-campaigns it does appear specific for that class.

If you change that test broadcast so that your class replaces com.google.analytics.tracking.android.AnalyticsReceiver you can then receive it. The biggest problem is they seemed to have locked down this class in beta 4 or 5. If anyone has a link to beta 3 we could test this, or if xbakex could confirm with playing around with the new jars that would rock!

Update:

BAM! So permissions are not an issue. I created a test project and used the PlayStores alpha testing to test out referrer links, which you can build here: https://developers.google.com/analytics/devguides/collection/android/v2/campaigns.

The cool thing is you don't need any GA jar at all! Checkout my test project here: https://github.com/twotoasters/AnalyticsTest/ This project also shows you how to parse the link to get all of the information that you need.

like image 76
MinceMan Avatar answered Oct 09 '22 11:10

MinceMan