整合分析不起作用

时间:2015-06-28 20:52:02

标签: android google-analytics

我尝试将google Analytics集成到我的应用程序中,但它不起作用。

这是我的Activity

public class InhaltsverzeichnisActivity extends Activity {

private SharedPreferencesManager prefs; //added

private InterstitialAd Interstitial;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.inhaltsverzeichnis);

    prefs = new SharedPreferencesManager(this); //get SharedPreferencesManager  instance
    int t = prefs.retrieveInt("theme", 0); //get stored theme, zero is default
    ThemeUtils.setTheme(t);  //Set the stored theme, will default to Black

    Tracker t1 = ((AnalyticsSampleApp)this.getApplication()).getTracker(TrackerName.APP_TRACKER);
    t1.setScreenName("Inhaltsverzeichnis");
    t1.send(new HitBuilders.AppViewBuilder().build());

    Interstitial = new InterstitialAd(this);
    Interstitial.setAdUnitId("ca-app-pub-XXXXXXXXXXXXX/XXXXXXXXXX");
    AdRequest adRequest = new AdRequest.Builder().build();
    Interstitial.loadAd(adRequest);

        ;
        Interstitial.setAdListener(new AdListener(){
            public void onAdLoaded(){
                 displayInterstitial();
                 Interstitial.show();
    }
        });
}

protected void displayInterstitial() {
    // TODO Auto-generated method stub
}
    public void onDismissScreen() {
        // TODO Auto-generated method stub

    }
    public void onFailedToReceiveAd() {
        // TODO Auto-generated method stub

    }
    public void onLeaveApplication() {
        // TODO Auto-generated method stub

    }
    public void onPresentScreen() {
        // TODO Auto-generated method stub

    }
    @Override
       protected void onStart() {
          super.onStart();
          GoogleAnalytics.getInstance(InhaltsverzeichnisActivity.this).reportActivityStart(this);
       }

       @Override
       protected void onStop() {
          super.onStop();
          GoogleAnalytics.getInstance(InhaltsverzeichnisActivity.this).reportActivityStop(this);
       }

如果我将OnStart和OnStop方法放在非页内广告上,Google Analytics就会有效,但插页式广告会变得疯狂并且每秒都会出现,

希望有人能帮助我解决这个问题,谢谢。

0 个答案:

没有答案