私はad-mobインタースティシャル広告とバナー広告を追加したいウェブビューアンドロイドアプリを作成しています。既にそのコードを実装しています。ウェブビューアプリで同じコードを試してみると、インタースティシャル広告のみが動作します。誰かが正しいコードで私を助けてくれますか?以下のコードはWebviewアプリがadmobバナー広告を表示していない
build.gradle
compile 'com.google.android.gms:play-services-ads:9.2.0'
activity_main.xml
<WebView
android:id="@+id/activity_main_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
MainActivity.java
InterstitialAd mInterstitialAd;
private InterstitialAd interstitial;
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId(getString(R.string.admob_interstitial_id));
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
}
のstrings.xml
<string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>
<string name="admob_interstitial_id">ca-app-pub-3940256099942544/1033173712</string>
あります3210
作業このコードを試してくださいあなたのレイアウトファイルを投稿webview.iのwebviewは重複していると思うバナービュー –
@MohitMadaan –
私が編集し、ウェブを追加しましたメインの質問でもレイアウトを見ることができます。 –