gpt4 book ai didi

android - admob : changing ads

转载 作者:行者123 更新时间:2023-11-29 16:10:50 26 4
gpt4 key购买 nike

我使用以下代码在 Activity 的 onCreate() 中展示广告由于我的 Activity 显示时间较长,我可以刷新广告吗?还是会自动刷新它们?我什至需要更改它们还是不应该打扰它?

        //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);

最佳答案

更改 admob 帐户中的应用设置:

enter image description here

另外你应该在发布之前移除测试模式:

    AdView adView = (AdView) findViewById(R.id.ad);
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);

在 onDestroy() 中:adView.destroy();

在布局中:

<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>

在 AdMob 应用设置中选择:禁用所有请求的测试模式

关于android - admob : changing ads,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13546318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com