Put the advertisement in the application, but the advertisement is not displayed.

The identifier in the string resource is

In OnCreate, the following code:

// Create the InterstitialAd and set the adUnitId. mInterstitialAd = new InterstitialAd(this); // Defined in res/values/strings.xml mInterstitialAd.setAdUnitId(getString(R.string.ad_unit_id)); mInterstitialAd.loadAd(new AdRequest.Builder().build());{ } 

Advertising should be called by clicking on the button, has the following code:

  case R.id.progIm: // НаТатиС Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡƒ mInterstitialAd.setAdListener(new AdListener() { @Override public void onAdClosed() { super.onAdClosed(); //дСйствиС1 } }); if (mInterstitialAd.isLoaded()) { mInterstitialAd.show(); } else{ //дСйствиС1 mInterstitialAd.loadAd(new AdRequest.Builder().build());{ } } break; 

Manifesto

 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <application tools:replace="android:icon" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:screenOrientation="portrait" android:theme="@style/AppTheme"> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/> <activity android:name=".SplashActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".PlayGameActivity"> </activity> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" /> </application> 

Identifier

 <string name="ad_unit_id">ca-app-pub-XXXXXXXXXXX</string> 

In the logs when you click on the button gives some links. Advertising also does not show the following:

05-17 17: 20: 01.861 7614-7614 / com.eddev.intellecualtechical W / Ads: JS: The page at https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk- core-v40.html displayed insecure content from file: ///android_asset/webkit/android-weberror.png. (null: 1) 05-17 17: 20: 01.861 7614-7614 / com.eddev.intellecualtechical W / Web Console: The page at https://googleads.g.doubleclick.net/mads/static/mad/sdk/ native / sdk-core-v40.html displayed insecure content from file: ///android_asset/webkit/android-weberror.png. at null: 1

    1 answer 1

    It may not be necessary to reload the advertisement every time and immediately try to show it while it is still not loaded.

    Those. first try to show it and, if it is not loaded, then only load it.