adloader.java
public class AdLoader {
public InterstitialAd mInterstitialAd;
public InterstitialAd wInterstitialAd;
public static AdLoader adLoader;
public static AdLoader getAds() {
if (adLoader == null) {
adLoader = new AdLoader();
}
return adLoader;
}
public void loadFullAdmob(Context context) {
mInterstitialAd = new InterstitialAd(context);
mInterstitialAd.setAdUnitId(context.getString(R.string.admob_unit_id));
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
public void showAdmob(Activity activity) {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
loadFullAdmob(activity);
}
}
我在这行收到错误警报:
mInterstitialAd = new InterstitialAd(context);
可能是上下文的问题,我不知道如何解决。
我在mainactivity.java中也有这个
AdLoader.getAds().loadFullAdmob(this);
1条答案
按热度按时间wn9m85ua1#
使用此最新代码检查此视频