我有插页式广告的问题。如何为插页式广告添加阈值?
private void setupInterstitial() {
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-XXXXXXXXXXXXXXXXXXXXXXXXX");
requestNewInterstitial();
}
private void requestNewInterstitial() {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("SEE_YOUR_LOGCAT_TO_GET_YOUR_DEVICE_ID")
.build();
mInterstitialAd.loadAd(adRequest);
}
protected void bindViews() {
ButterKnife.bind(this);
setupToolbar();
}
protected void setupToolbar() {
if (mToolbar != null) {
setSupportActionBar(mToolbar);
}
mNavigationView.setNavigationItemSelectedListener(mNavigationListener);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.hello_world, R.string.hello_world);
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
public Toolbar getToolbar() {
return mToolbar;
}
protected void setHamburgerButton() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
}