4

我收到此错误“I/GAV4(7915): Thread[GAThread,5,main]: 未找到活动数据。” 有人知道我出了什么问题吗?

  • 我正在使用 android API 级别 20
  • 谷歌分析 v4
  • 安卓设备 4.2.2
  • 常量.TRACKER_MainActivity = "MainActivity"

注意 - 我在代码中屏蔽了以下几个元素。

这是我的代码..清单

<application
        android:name="com.xxx.yyy.utility.Trackers"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data 
            android:name="com.google.android.gms.analytics.globalConfigResource"
            android:resource="@xml/global_tracker" />
        <activity
            android:name="com.xxx.yyy.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

跟踪器初始化

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="TypographyDashes">
  <integer name="ga_sessionTimeout">300</integer>

    <!-- Enable automatic Activity measurement -->
    <bool name="ga_autoActivityTracking">true</bool>

    <!-- The screen names that will appear in reports -->
    <screenName name="com.xxx.yyy.MainActivity">MainActivity</screenName>
    <!--  The following value should be replaced with correct property id. -->
    <string name="ga_trackingId">UA-YYYYYYY-X</string>
</resources>

Activity 中的代码 - onCreate //管理应用程序的跟踪器

t = ((Trackers) getApplication()).getTracker(Trackers.TrackerName.GLOBAL_TRACKER);

onResume //发送简历到分析

t.setScreenName(Constants.TRACKER_MainActivity);
t.send(new HitBuilders.AppViewBuilder().build());

追踪器应用类

public class Trackers extends Application
{
    public enum TrackerName
    {
        APP_TRACKER, // Tracker used only in this
                        // app.
        GLOBAL_TRACKER, // Tracker used by all the
                        // apps from a company.
                        // eg: roll-up tracking.
        ECOMMERCE_TRACKER, // Tracker used by all
                            // ecommerce
                            // transactions from a
                            // company.
    }

    HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();

    public synchronized Tracker getTracker(TrackerName trackerId)
    {
        if (!mTrackers.containsKey(trackerId))
        {
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
            if( trackerId == TrackerName.GLOBAL_TRACKER )
            {
                mTrackers.put(trackerId, analytics.newTracker(R.xml.global_tracker));
            }
        }
        return mTrackers.get(trackerId);
    }
}
4

2 回答 2

1

好的,这东西很好用。我正在查看 Google Analytics 中的应用程序概览。报告不是在那里实时生成的。Google Analytics 下有一个用于实时报告的特定选项卡。这是我们需要看到的地方。

于 2014-07-16T06:00:48.407 回答
0

为此,在 GoogleAnalyticsv4 中制作 CustomReceiver 并从该发送意图到 google CampaignTrackingReceiver。

这样,您将在日志中获得CampaignFound

public class CustomCampaignTrackingReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

new CampaignTrackingReceiver().onReceive(context, intent);
}
}
于 2015-03-13T10:05:15.317 回答