当用户通过点击Facebook 上的Ad 或者Google AD 跳转到GooglePlay 商店,我们的应用如何获知这个引荐来源,可通过使用Play Install Referrer 库还获知。
Play Install Referrer 库
错误1:
使用过程中会发现无论设备是否有安装GoogleService, 都会偶发性产生如下崩溃:
Fatal Exception: java.lang.RuntimeException: Unable to resume activity
{**}:java.lang.SecurityException: Not allowed to bind to service Intent
{ act=com.google.android.finsky.BIND_GET_INSTALL_REFERRER_SERVICE cmp=com.android.vending/com.google.android.finsky.externalreferrer.GetInstallReferrerService }
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3216)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3247)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1458)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5619)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:737)
可通过下面try....catch方案进行处理:
try {
mReferrerClient.startConnection(installReferrerStateListener);
} catch (RuntimeException e) {
CrashLoggingUtils.logException(e, T.UTILS);
AppLog.e(T.UTILS, "installation referrer start connection failed!", e);
AnalyticsTracker.track(Stat.INSTALLATION_REFERRER_FAILED);
// just bail if we were not able to connect to the installation referrer service
stopService();
}
网友评论