Android的AdMob的例子 [英] Android AdMob example

查看:102
本文介绍了Android的AdMob的例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了例如$ C $的Andr​​oid项目从的此处。在图片中,广告中说AdMob的测试Android的网络广告,但是当我运行code,我有时会看到一个实际的广告,有时什么也看不见。为什么呢?

I downloaded example code of an Android project featuring AdMob ads from here. In the picture, the ad says "AdMob Test Android Web Ad", but when I run the code, I sometimes see an actual ad and sometimes see nothing. Why?

推荐答案

确保测试模式在模拟器启用。似乎是code中的链接没有它的测试模式使能。

Ensure that test mode is enabled on emulator. Seems like the code in the link does not have it's test mode enable.

广告不启动应用程序后立即运行。这将需要几秒钟(最多10secs,这取决于你的网络速度)之前能够从Admob的接收广告。

Ads do not run immediately after launching the application. It would take a couple of seconds(up to 10secs, depending on your network speed) before being able to receive an advertisement from Admob.

尝试像这样在你的onCreate()。

Try something like this in your onCreate().

    adView = new AdView(this, AdSize.BANNER, "a9876sf98dfg");        
    RelativeLayout layout = (RelativeLayout)findViewById(R.id.ad);        
    layout.addView(adView);
    AdRequest request = new AdRequest();
    request.setTesting(false);
    adView.loadAd(request);

编辑(从评论):请按照edumobile.org/android/android-development/admob-manager的说明,但增加了该行机器人:ID =@ + ID / LinearLayout中以主力的LinearLayout部分的.xml。

EDIT (from the comments): Follow the instructions on edumobile.org/android/android-development/admob-manager, but add the line "android:id="@+id/linearLayout" to the LinearLayout part of main.xml.

这篇关于Android的AdMob的例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆