我曾经在我未来的应用上展示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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
导入正常,Google Play服务库当然是导入的.
我使用此示例: AdMob Android指南 - 非页内广告.
有人能告诉我我的代码有什么问题吗?