我希望能够使用Google Analytics追踪AdMob横幅广告的点击量,但出现了问题,我不知道原因。
目前,我的AdMob横幅广告是这样实现的:
布局:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="YOUR_AD_UNIT_ID"
ads:adSize="BANNER"/>
Java: AdView adView = (AdView) this.findViewById(R.id.adView);
然而,谷歌的演示项目(展示如何添加AdListener)(可在此处获取项目)没有在布局中指定任何内容,并使用以下代码添加横幅广告:
LinearLayout layout = (LinearLayout) findViewById(R.id.leLinearLayoutDeMonChoix);
layout.addView(adView);
但是如果使用开头描述的实现方式,AdListener将不再检测到任何事件。为什么呢?
您可以在以下演示项目中找到这个有缺陷的实现:https://drive.google.com/file/d/0B8rE1pbtzNJ1UXg5QllubEFidGc/edit?usp=sharing 非常感谢您的时间和帮助。