错误Admob插页式广告构造函数InterstitialAd(MenuActivity)未定义

时间:2014-04-06 02:52:56

标签: android admob ads interstitial

我已根据https://developers.google.com/mobile-ads-sdk/docs/admob/advanced编写了将admob中的插页式广告添加到我应用的菜单活动中的代码。我也在Manifest中添加了PERMISSIONS和configchanges。我在下面提到的行中遇到错误:

`

    interstitial = new InterstitialAd(this); // Error: The constructor InterstitialAd(MenuActivity) is undefined

    interstitial.setAdUnitId("lajdID"); // Error: The method setAdUnitId(String) is undefined for the type InterstitialAd

    // Create ad request.
    AdRequest adRequest = new AdRequest.Builder().build(); //AdRequest.Builder cannot be resolved to a type

    // Begin loading your interstitial.
    interstitial.loadAd(adRequest);

`

2 个答案:

答案 0 :(得分:0)

您应该从;

导入admob
import com.google.android.gms.ads.*;

答案 1 :(得分:0)

错误告诉您MenuActivity不是android.app.Activity的实例。