通过引用来自Play商店安装时应用程序挂起

时间:2016-02-27 09:10:54

标签: android google-play install-referrer

我在Play商店有一个Android应用程序。从referrer网址安装并直接从Play商店打开后,它会挂起并且apaplication崩溃,就像在UI线程上做很多工作一样,我在清单中有两个广播接收器用于INSTALL_REFERRER,一个用于分析目的,另一个用于设置一些报警。出于分析目的,我正在提取utm source,medium,campaign id ...这是非常轻量级的操作,但我仍在IntentService上进行,

代码

 @Override
 protected void onHandleIntent(Intent intent) {
        getUtmValuesAndSave(UtmCreateService.this, intent);
 }

private void getUtmValuesAndSave(Context context, Intent intent) {

        String referrer = intent.getStringExtra(Constants.UTM_REFERRER);

        String source = getSourceFromReferrer(referrer);

        saveSourceInPreference(context, source);
}

private static String getSourceFromReferrer(String referrer) {

        StringBuilder sourceBuilder = new StringBuilder();
        String source = null;

        try {
            referrer = URLDecoder.decode(referrer, "UTF-8");
            String[] utms = referrer.split("&");

                String utm = getUtmValue(utms, Constants.UTM_SOURCE);
                sourceBuilder.append(Constants.UTM_SOURCE).append("=").append(utm).append("&");
                utm = getUtmValue(utms, Constants.UTM_CAMPAIGN);
                sourceBuilder.append(Constants.UTM_CAMPAIGN).append("=").append(utm).append
                        ("&");
                utm = getUtmValue(utms, Constants.UTM_ANID);
                sourceBuilder.append(Constants.SERVER_UTM_ADGROUPID).append("=").append(utm);


        } catch (Exception e) {
            e.printStackTrace();
        }
        source = sourceBuilder.toString();
        return source;
    }

    /**
     * read utm value for the given key
     *
     * @param utms utm string array, contains all the utm fields
     * @param key  key
     * @return value of the key in utm
     */
    private static String getUtmValue(String[] utms, String key) {
        String utm = null;
        boolean foundUtm = false;

        for (String utm1 : utms) {
            utm = utm1;

            if (utm.contains(key)) {
                foundUtm = true;
                utm = utm.split("=")[1];
                break;
            }
        }

        if (!foundUtm) {
            utm = "Null";
        }
        return utm;
    }

**清单**

<receiver
    android:name=".receiver.AnalyticsReceiver"
    android:enabled="true"
    android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

<receiver android:name=".receiver.AlarmStartReceiver"
          android:enabled="true"
          android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER"/>
    </intent-filter>
</receiver>

这可能是什么问题?如果我直接从Play商店安装应用程序(没有引用网址,那么它工作正常)。我检查了logcat日志,我看到了多次接收器调用

修改

我已经使用此adb命令adb shell am broadcast -a com.android.vending.INSTALL_REFERRER --es "referrer" "utm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_term%3Dtest%2520fund%26utm_content%3Dnew%2520ad%26utm_campaign%3Dtest%26anid%3Dadmob;测试了应用程序,我发现它反复调用INSTALL_REFERRER接收器。

更新,从Play商店安装时记录

MultipleInstallBroadcastReceiver.onReceive(MultipleInstallBroadcastReceiver.java:31)
02-27 17:11:46.840 21946-21946/my.package.name W/logd: Dropped 2
02-27 17:11:46.840 21946-21946/my.package.name E/art:     at my.package.name.receiver.CommonAnalyticsTrackingReceiver.onReceive(CommonAnalyticsTrackingReceiver.java:29)
02-27 17:11:46.840 21946-21946/my.package.name W/logd: Dropped 3
02-27 17:11:46.840 21946-21946/my.package.name E/art:     at my.package.name.receiver.CommonAnalyticsTrackingReceiver.onReceive(CommonAnalyticsTrackingReceiver.java:29)
02-27 17:11:46.840 21946-21946/my.package.name W/logd: Dropped 2
02-27 17:11:46.840 21946-21946/my.package.name E/art:     at com.appsflyer.MultipleInstallBroadcastReceiver.onReceive(MultipleInstallBroadcastReceiver.java:31)
02-27 17:11:46.840 21946-21946/my.package.name W/logd: Dropped 2
02-27 17:11:46.840 21946-21946/my.package.name E/art:     at my.package.name.receiver.CommonAnalyticsTrackingReceiver.onReceive(AnalyticsTrackingReceiver.java:29)
02-27 17:11:46.840 21946-21946/my.package.name W/logd: Dropped 3

这是从Play商店安装时的日志,大约1000次。

0 个答案:

没有答案