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:
`package com.website.test; import com.google.android.gms.ads.InterstitialAd;
public class AdManager {
// Static fields are shared between all instances. static InterstitialAd ad;
public AdManager() { createAd(); }
public void createAd() { // Create an ad. interstitialAd = new InterstitialAd(this); interstitialAd.setAdUnitId("");
AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice(TEST_DEVICE_ID).build(); // Load the interstitial ad. interstitialAd.loadAd(adRequest); } public InterstitialAd getAd() { return ad;}}
In create event of class A i put this :
AdManager adManager = new AdManager();
adManager.createAd();
- In create event of the activity which i want show interstitial ad i put this :
InterstitialAd ad = admanager.getAd();
if (ad.isLoaded) {
ad.show();
}
but there are some errors as it shown in the pics i attached , please tell me what is wrong ?