我在Google Play上有财务申请,我在应用中每天有800名活跃用户。有些时候AdMob banner和interstitialAd没有加载,它会显示白色横幅代替广告。下面的Java代码:
AdView adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("CA626566A7B365501AE304BBA64A11D9")
.build();
adView.loadAd(adRequest);
的test.xml
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id" />
AdsUtil.java //这是我的interstitialAd java类,当用户返回任何屏幕然后我调用showInterstitial();
public class AdsUtil {
private InterstitialAd mInterstitialAd;
private Context context;
public AdsUtil(Context context){
this.context=context;
mInterstitialAd = newInterstitialAd();
loadInterstitial();
}
private InterstitialAd newInterstitialAd() {
InterstitialAd interstitialAd = new InterstitialAd(context);
interstitialAd.setAdUnitId(context.getString(R.string.interstitial_ad_unit_id));
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// mNextLevelButton.setEnabled(true);
}
@Override
public void onAdFailedToLoad(int errorCode) {
// mNextLevelButton.setEnabled(true);
}
@Override
public void onAdClosed() {
// Proceed to the next level.
goToNextLevel();
}
});
return interstitialAd;
}
public void showInterstitial() {
// Show the ad if it's ready. Otherwise toast and reload the ad.
if(!Utility.getSharedPreferencesBoolean(context, Constant.isPrimeUser) && Constant.adsFlag ) {
Constant.adsFlag=false;
timerAds();
if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
goToNextLevel();
}
}
}
private void loadInterstitial() {
// Disable the next level button and load the ad.
// mNextLevelButton.setEnabled(false);
AdRequest adRequest = new AdRequest.Builder().build();
// .setRequestAgent("android_studio:ad_template").build();
mInterstitialAd.loadAd(adRequest);
}
private void goToNextLevel() {
// Show the next level and reload the ad to prepare for the level after.
// mLevelTextView.setText("Level " + (++mLevel));
mInterstitialAd = newInterstitialAd();
loadInterstitial();
}
private void timerAds(){
new CountDownTimer(1000*10*1, 1000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
Constant.adsFlag=true;
}
}.start();
}
}
答案 0 :(得分:0)
这是因为有两个原因,