我一直在努力让 Google 分析应用到我的应用程序小部件中,但没有取得任何成功,该代码在从 Activity 使用时工作正常,但在应用程序小部件中则不然。
最佳答案
您好,请在 AppWidgetProvider onEnabled() 方法中使用此代码
Tracker t = ((MyApplication) context.getApplicationContext()).getTracker(
MyApplication.TrackerName.APP_TRACKER);
// Set screen name.
t.setScreenName(screenName);
// Send a screen view.
t.send(new HitBuilders.AppViewBuilder().build());
关于android-widget - 如何将 Google Analytics 添加到 Android 应用程序小部件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13803232/