protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged (e);

            mainView = e.NewElement as MainView;
            if (mainView != null) {

            }
        }
 protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Page> e)
 {
     base.OnElementChanged(e);
     mainView = e.NewElement as MainView;
 }
 protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
 {
     base.OnElementChanged (e);
     mainView = e.NewElement as MainView;
     sensorManager = (SensorManager)Context.GetSystemService (Context.SensorService);
     sensor = sensorManager.GetDefaultSensor (Android.Hardware.SensorType.Accelerometer);
     sensorManager.RegisterListener (this, sensor, Android.Hardware.SensorDelay.Game);
 }
 protected override void OnDetachedFromWindow()
 {
     mainView = null;
     sensorManager.UnregisterListener (this);
 }