如何创建Android广告插播式广告? [英] How to create android Ad Interstitials?
本文介绍了如何创建Android广告插播式广告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不明白它在InterstitialAd和我coudnt找到任何example.if你有一个例子,你可以发布它。我尝试旗帜,是它的工作原理。但是当我尝试在InterstitialAd我得到error.i希望当我打开应用程序,我想看到的广告。
i dont get it InterstitialAd and i coudnt find any example.if you have a example, can you post it .i try banner is it works . but when i try InterstitialAd i get error.i want when i open app i wanna see ads .
谢谢!
package com.example.reklam3;
import android.app.Activity;
import com.google.ads.*;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.google.ads.Ad;
import com.google.ads.AdListener;
import com.google.ads.AdRequest;
import com.google.ads.AdRequest.ErrorCode;
import com.google.ads.InterstitialAd;
public class MainActivity extends Activity implements AdListener{
private InterstitialAd interstitial;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the interstitial
interstitial = new InterstitialAd(this,"ca-app-pub-90707885707358xx");
// Create ad request
AdRequest adRequest = new AdRequest();
// Begin loading your interstitial
interstitial.loadAd(adRequest);
// Set Ad Listener to use the callbacks below
interstitial.show();
}
@Override
public void onReceiveAd(Ad ad) {
Log.d("OK", "Received ad");
if (ad == interstitial) {
interstitial.show();
}
}
@Override
public void onDismissScreen(Ad arg0) {
// TODO Auto-generated method stub
}
@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
// TODO Auto-generated method stub
}
@Override
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub
}
@Override
public void onPresentScreen(Ad arg0) {
// TODO Auto-generated method stub
}
}
如果你有一个sipmle〔实施例,你可以将它张贴.ty
if you have a sipmle examle can you post it .ty
推荐答案
我刚刚发布了关于这个问题在这里的答案:
I just posted an answer about this question here:
<一个href=\"http://stackoverflow.com/a/24150614/1287856\">http://stackoverflow.com/a/24150614/1287856
基本上,你需要:
- 呼叫
adRequest.build()
在//开始加载插页式
- Call
adRequest.build()
before// Begin loading your interstitial
这篇关于如何创建Android广告插播式广告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文