forked from kjundev/Xamarin.Android-AdMob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainActivity.cs
34 lines (29 loc) · 843 Bytes
/
MainActivity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Android.App;
using Android.Widget;
using Android.OS;
using Android.Gms.Ads;
namespace AdMob
{
[Activity(Label = "AdMob", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected AdView adView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
adView = FindViewById<AdView>(Resource.Id.adView);
var adRequest = new AdRequest.Builder().Build();
adView.LoadAd(adRequest);
}
protected override void OnResume()
{
base.OnResume();
if (adView != null)
{
adView.Resume();
}
}
}
}