App ID: ca-app-pub-7495491813684464~4849458816
Ad unit name: Interstitial
Ad unit ID: ca-app-pub-7495491813684464/1156468269
private void initGoogleAds() {
MobileAds.initialize(getActivity(), Constants.ADMOB_APP_ID);
mInterstitialAd = new InterstitialAd(getActivity());
mInterstitialAd.setAdUnitId(Constants.ADMOB_AD_UNIT_ID);
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
startLoadAd();
}
});
startLoadAd();
}
private void startLoadAd() {
TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
deviceId = tm.getDeviceId();
Log.d("deviceIdTest", deviceId + "");
if (!mInterstitialAd.isLoading() && !mInterstitialAd.isLoaded()) {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mInterstitialAd.loadAd(adRequest);
}
ivAdsText.setBackgroundResource(R.drawable.text_ad_gray);
ivAds.setBackgroundResource(R.drawable.sun_ad_gray);
if (mDrawable != null) {
mDrawable.stop();
}
resumeLoadAd(GAME_LENGTH_MILLISECONDS);
}private void showInterstitial() {
// Show the ad if it's ready. Otherwise toast and restart the game.
if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Toast.makeText(getActivity()
, "Ad did not load", Toast.LENGTH_SHORT).show();
startLoadAd();
}
}
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />