我正在使用最新版本的 Google Play 服务,以便将 Google Analytics(分析)与我的 Android 应用结合使用。我尝试将调度间隔设置为仅 1 秒,以便我可以在实时分析仪表板中看到它。但是,至少需要 3 分钟才能实时显示。我怎样才能让它立即或一分钟内显示?
这是我的代码:
GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
final Tracker t = analytics.newTracker("UA-XXXXX-X");
analytics.setLocalDispatchPeriod(1);
我需要以编程方式完成此操作,而不是在 XML 文件中。 我还应该提到我正在跟踪一个事件。 3 分钟后,它似乎始终出现在实时分析中。
感谢您的帮助。
最佳答案
setLocalDispatchPeriod()
现已弃用一段时间了。
The reason for the deprecation is outlined in the ServiceManager JavaDoc:
This only works if local dispatching is in use. Local dispatching is only used in the absence of Google Play Services on the device or if manually forced (see setForceLocalDispatch()). In general, applications can not rely on the ability to set the dispatch period. This method should therefore be used with some discretion.
If you are using EasyTracker, you can also specify ga_dispatchPeriod in your analytics.xml file, which should not throw a lint warning about deprecation.
<resources>
<string name="ga_trackingId">UA-XXXXXXXX-X</string>
<integer name="ga_dispatchPeriod">1</integer>
<!-- [...] -->
</resources>
关于android - Android 的 Google Analytics 调度周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24539116/