How to Implement Admob Interstitial Ads in Android Studio|| Interstitial ads 2020
Google Test ID :
1. Sample AdMob App test ID: ca-app-pub-3940256099942544~33475117132. Interstitial test ID : ca-app-pub-3940256099942544/1033173712
How To Get Device ID for testing ads
1. open LOGCAT in Android Studio
2. in search box search addtestdevice
3. you will get your device id
4. to add test device
AdRequest request = new AdRequest.Builder()
.addTestDevice("your device id")
.build();
1: In Mainactivity.java
in package :
import com.google.android.gms.ads.InterstitialAd;
in public class :
private InterstitialAd mInterstitialAd;
in protected void : mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
mInterstitialAd.loadAd(new AdRequest.Builder()
.build());
in public void onBackPressed: replace all this
{
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
if (mywebView.canGoBack()) {
mywebView.goBack();
} else {
super.onBackPressed();
}
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
if (mywebView.canGoBack()) {
mywebView.goBack();
} else {
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}}});
2 Comments
This comment has been removed by the author.
ReplyDeleteI have seen your youtube video and i came here thank you so much for helping :-)
ReplyDeleteI couldn't find this in the updated version could you please help me
WARNING:
Don't do spam comments!