[英]Admob not showing Ads
我曾經在未來的應用程序中展示AdMob標語,然后嘗試插頁式廣告。 我檢查了AdMob SDK的實現,並復制了它們的示例源,因為它正是我想要的(即,活動啟動時顯示的插頁式廣告)。 我在模擬器和銀河上進行了嘗試,未顯示任何廣告。 這是源代碼。
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();
}
}
}
導入還可以,當然它們是谷歌搜索服務庫。 我使用以下示例: https : //developers.google.com/mobile-ads-sdk/docs/admob/advanced
有人可以告訴我我的代碼有什么問題嗎?
提前致謝 !
您的代碼沒有錯。
但是可能沒有任何廣告可以顯示。 建議你
我認為您遵循了官方的admob指南,卻忘記了在onCreate方法中添加偵聽器,如下所示:
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
displayInterstitial(interstitial);
}
});
如果您需要進一步的幫助,例如有關使用非UI線程中的插頁式廣告的信息,請參見以下信息: http : //www.6020peaks.com/2015/01/how-to-use-admob-來自非ui線程在Android /中的非頁內廣告
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.