0
我正在嘗試在我的應用中整合Admob SmartBanner和插頁式廣告。 SmartBanner工作正常,但插頁式廣告未加載。Admob插頁式廣告未在Android中的片段中加載
在同一個應用程序中集成admob banner + interstitial add的正確代碼是什麼?
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home, container, false);
//------------------------------------------------------------------------------------------
AdView mAdView = (AdView) rootView.findViewById(R.id.adView);
final AdRequest.Builder request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators
.addTestDevice("1E085E6103A6876F42FC5183C73D98CB");//genymotion galaxy s5 4.4.4
mAdView.loadAd(request.build());
mInterstitialAd = new InterstitialAd(getActivity());
mInterstitialAd.setAdUnitId(String.valueOf(R.string.banner_ad_unit_id));//("ca-app-pub-5059726881726792/4446999064");
//final AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
//adRequestBuilder.addTestDevice("1E085E6103A6876F42FC5183C73D98CB")//genymotion galaxy s5 4.4.4
// .addTestDevice("0B80CC732BD7E24CF42938649A17A7DA");//s3
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
}
@Override
public void onAdClosed() {
super.onAdClosed();
mInterstitialAd.loadAd(request.build());
}
});
mInterstitialAd.loadAd(request.build());
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
它爲我用'com.google.android.gms:發揮服務的廣告:11.0。 4' –