i want load interstitial ad in activity and show it in another activity . i found this topic and try to do the steps in the first answer but there are a lot errors .
How To preload admob interstitial ad and send to another android activity using intent
That what i did :
I created a public class and named it "AdManager" and put this code in it:
but there are some errors as it shown in the pics i attached , please tell me what is wrong ?
How To preload admob interstitial ad and send to another android activity using intent
That what i did :
I created a public class and named it "AdManager" and put this code in it:
- `package com.website.test;
import com.google.android.gms.ads.InterstitialAd;
publicclassAdManager{
// Static fields are shared between all instances.
staticInterstitialAd ad;
publicAdManager(){
createAd();
}
publicvoid createAd(){
// Create an ad.
interstitialAd =newInterstitialAd(this);
interstitialAd.setAdUnitId("");
AdRequest adRequest =newAdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(TEST_DEVICE_ID).build();
// Load the interstitial ad.
interstitialAd.loadAd(adRequest);
}
publicInterstitialAd getAd(){
return ad;}}
- In create event of class A i put this :
- In create event of the activity which i want show interstitial ad i put this :
but there are some errors as it shown in the pics i attached , please tell me what is wrong ?