Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            OS.AutoDisposedGL = false;

            // Screen orientation
            var requiredOrientation = (desc.Orientation == ApplicationOrientations.Landscape) ? Android.Content.PM.ScreenOrientation.Landscape : Android.Content.PM.ScreenOrientation.Portrait;

            RequestedOrientation = requiredOrientation;

            // Remove title bar
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            // Create gl view
            VolumeControlStream = Android.Media.Stream.Music;
            view = new GLView(this);
            SetContentView(view);

            // Ads
            if (desc.UseAds)
            {
                adMobView = AdMobWrapper.CreateAdView(this, desc.PublisherID);
                var layout = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent, FrameLayout.LayoutParams.WrapContent, GravityFlags.Bottom);
                AddContentView(adMobView, layout);
                AdMobWrapper.LoadAd(adMobView, false);
                adMobView.Visibility = Android.Views.ViewStates.Visible;
                adMobView.BringToFront();
            }

            // keep screen from locking
            var power = (PowerManager)GetSystemService(Context.PowerService);

            wakeLock = power.NewWakeLock(WakeLockFlags.ScreenDim, "AndroidApplication");
        }
Пример #2
0
 protected override void OnDestroy()
 {
     OS.AutoDisposedGL = true;
     if (adMobView != null)
     {
         var group = view.Parent as ViewGroup;
         if (group != null)
         {
             group.RemoveView(adMobView);
         }
         AdMobWrapper.Destroy(adMobView);
     }
     Closing();
     base.OnDestroy();
 }