本文介绍了AdMob的:改变广告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面的code,显示广告在活动的onCreate()由于我的活动显示更长的时间,我可以刷新的广告?还是会自动刷新呢?难道我甚至需要更改它们或不应该打扰吗?
//只要求测试广告,在模拟器,应在真实设备稍后删除
AdRequest adRequest =新AdRequest();
//adRequest.addTestDevice(AdRequest.TEST_EMULATOR); //模拟器
//adRequest.addTestDevice("TEST_DEVICE_ID);
//创建AD浏览报
AD浏览报=新的AD浏览报(这一点,AdSize.BANNER,908908098098);
//查找您的LinearLayout假设它是被赋予了
//属性机器人:ID =@ + ID / mainLayout
的LinearLayout布局=(的LinearLayout)findViewById(R.id.adLayout);
// AD浏览报给它添加
layout.addView(AD浏览报);
//初始化一个通用的请求与广告加载
adView.loadAd(adRequest);
解决方案
在AdMob的账户更改应用程序设置:
你也应该发布之前删除测试模式:
AD浏览报AD浏览报=(AD浏览报)findViewById(R.id.ad);
AdRequest adRequest =新AdRequest();
adView.loadAd(adRequest);
在的onDestroy(): adView.destroy();
在布局:
< com.google.ads.AdView
机器人:ID =@ + ID /广告
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_alignParentRight =真
机器人:layout_alignParentTop =真
广告:adSize =大旗
广告:adUnitId =@字符串/ admob_publisher_id
广告:loadAdOnCreate =真正的>
< /com.google.ads.AdView>
在AdMob的应用程序设置选择此:禁用测试模式为所有请求
I use following code to show ads in onCreate() of the activitySince my activity is displayed for longer times, can I refresh the ads ? or will it automatically refresh them ? Do I even need to change them or should not bother it ?
//only ask for test ad, in emulator , should remove this later in real device
AdRequest adRequest = new AdRequest();
//adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Emulator
//adRequest.addTestDevice("TEST_DEVICE_ID");
// Create the adView
adView = new AdView(this, AdSize.BANNER, "908908098098");
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout)findViewById(R.id.adLayout);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(adRequest);
解决方案
Change app settings in admob account:
Also you should remove test mode before publishing:
AdView adView = (AdView) findViewById(R.id.ad);
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);
In onDestroy(): adView.destroy();
In layout:
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="@string/admob_publisher_id"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
In AdMob app settings select this: Disable test mode for all requests
这篇关于AdMob的:改变广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!