0

I have written the code for adding interstitial ads from admob to my app's menu activity as per https://developers.google.com/mobile-ads-sdk/docs/admob/advanced. I have added PERMISSIONS and configchanges in Manifest too. I am getting error in the lines mentioned below:

`

    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 Answers2

0

You should import admob from;

import com.google.android.gms.ads.*;
Sinan Kozak
  • 3,236
  • 2
  • 26
  • 32
0

The error is telling you that MenuActivity is not an instance of android.app.Activity.

William
  • 20,150
  • 8
  • 49
  • 91
  • MenuActivity is the activity where I am using that code which I mentioned above. –  Apr 06 '14 at 05:21
  • Show the code for MenuActivity, because the compiler is telling you that MenuActvity is not an Activity. – William Apr 06 '14 at 05:22