【发布时间】:2014-02-07 23:23:23
【问题描述】:
我曾经在我未来的应用程序中显示 AdMob 横幅,我想尝试一下插页式广告。我检查了 AdMob SDK 的实施情况,并复制了他们的示例源代码,因为这正是我想要的(即活动启动时显示的插页式广告)。我在模拟器和我的 Galaxy 上尝试过,没有显示任何广告。这是源代码。
public class Asscreed extends Activity {
private InterstitialAd interstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_asscreed);
// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("ca-app-pub-6046034785851961/xxxxxx");
// Create ad request.
AdRequest adRequest = new AdRequest.Builder().build();
// Begin loading your interstitial.
interstitial.loadAd(adRequest);
}
// Invoke displayInterstitial() when you are ready to display an interstitial.
public void displayInterstitial() {
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}
导入没问题,当然导入了他们的 googly play 服务库。我用这个例子:https://developers.google.com/mobile-ads-sdk/docs/admob/advanced
有人能告诉我我的代码有什么问题吗?
提前致谢!
【问题讨论】: