我曾经在我未来的应用程序中显示 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();
}
}
}
导入没问题,当然也导入了 Google Play 服务库。
我使用这个例子: AdMob Android Guides - Interstitial Ad。
有人可以告诉我我的代码有什么问题吗?