我从许多博客尝试过的东西,但没有一个给出一步一步的解决方案.我应该在AdMob网站上编辑某些内容吗?我是通过网站& amp;中的广告位/应用选项创建的.应用标签.
我用过这段代码:
interstitial = new InterstitialAd(this, "MyAdMobID");// Set Ad Listener to use the callbacks belowinterstitial.setAdListener(this);// Create ad requestAdRequest adRequest = new AdRequest();adRequest.addTestDevice(AdRequest.TEST_EMulATOR);// Begin loading your interstitial interstitial.loadAd(adRequest);adRequest.setTesting(true);
解决方法:
使用最后一个AndroID框架,我发现每次广告关闭时我都需要调用load()函数.
import com.Google.androID.gms.ads.*;import androID.os.Handler;import androID.os.Looper;import androID.app.Activity;class MyActivity extends Activity implements AdListener { private InterstitialAd adVIEw; // The ad private Handler mHandler; // Handler to display the ad on the UI thread private Runnable displayAd; // Code to execute to perform this operation @OverrIDe public voID onCreate(Bundle savedInstanceState) { adVIEw = new InterstitialAd(mContext); adVIEw.setAdUnitID("ca-app-pub-XXXXXXXXXX"); adVIEw.setAdListener(this); mHandler = new Handler(Looper.getMainLooper()); displayAd = new Runnable() { public voID run() { runOnUiThread(new Runnable() { public voID run() { if (adVIEw.isLoaded()) { adVIEw.show(); } } }); } }; loadAd(); } @OverrIDe public voID onAdClosed() { loadAd(); // Need to reload the Ad when it is closed. } voID loadAd() { AdRequest adRequest = new AdRequest.Builder() //.addTestDevice(AdRequest.DEVICE_ID_EMulATOR) .build(); // Load the adVIEw object witht he request adVIEw.loadAd(adRequest); } //Call displayInterstitial() once you are ready to display the ad. public voID displayInterstitial() { mHandler.postDelayed(displayAd, 1); }}
总结 以上是内存溢出为你收集整理的如何制作Android插页式广告?全部内容,希望文章能够帮你解决如何制作Android插页式广告?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)