0
我在我的项目中添加了google play service lib,之后我在清单文件中添加了admob的元数据和活动。然后,我在主要活动中添加了插页式广告代码,并调用displayinterstitial(),但它仍未显示广告。这些步骤中缺少什么?下面是我的代码。未能整合新的admob google play版插页式广告
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("APPID");
AdRequest adRequest = new AdRequest.Builder().build();
interstitial.loadAd(adRequest);
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getSupportActionBar();
SpannableString s = new SpannableString("Car Shop");
actionBar.setTitle(s);
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
public void displayInterstitial() {
if (interstitial.isLoaded()) {
interstitial.show();
}
}
@Override
public void onBackPressed() {.................}
@Override
public void onTabReselected(Tab arg0, FragmentTransaction arg1) {
// TODO Auto-generated method stub
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction arg1) {
viewPager.setCurrentItem(tab.getPosition());
displayInterstitial();
}
@Override
public void onTabUnselected(Tab arg0, FragmentTransaction arg1) {
// TODO Auto-generated method stub
}
}
我参考“https://developers.google.com/mobile-ads-sdk/docs/admob/advanced”编辑了我的代码。请看一看。仍未展示广告。 – user3217774
你需要告诉我们什么日志说 – William
logcat不显示任何有关admob。 – user3217774