Exemple #1
0
        static void RegisterShakeHandler()
        {
            var sensorManager = UIRuntime.GetService <SensorManager>(Context.SensorService);
            var sensor        = sensorManager.GetDefaultSensor(SensorType.Accelerometer);

            ShakeRecognizer = new ShakeRecognizer();
            sensorManager.RegisterListener(ShakeRecognizer, sensor, SensorDelay.Ui);
        }
Exemple #2
0
        static Task DoSetClipboard(string text, string label)
        {
            var clipboard = UIRuntime.GetService <ClipboardManager>(Context.ClipboardService);

            clipboard.PrimaryClip = ClipData.NewPlainText(label ?? string.Empty, text);

            return(Task.CompletedTask);
        }
Exemple #3
0
        static Sensors()
        {
            App.CameToForeground += () =>
            {
                if (Accelerometer.ShouldDetectShaking)
                {
                    Thread.Pool.RunActionOnNewThread(RegisterShakeHandler);
                }
            };

            App.WentIntoBackground += () =>
            {
                if (Accelerometer.ShouldDetectShaking)
                {
                    UIRuntime.GetService <SensorManager>(Context.SensorService).UnregisterListener(ShakeRecognizer);
                }
            };
        }
Exemple #4
0
 static Vibrator CreateVibrator() => UIRuntime.GetService <Vibrator>(Context.VibratorService);
Exemple #5
0
 internal static void Init()
 {
     Manager   = UIRuntime.GetService <LocationManager>(Context.LocationService);
     Providers = Manager.GetProviders(enabledOnly: false).Where(s => s != LocationManager.PassiveProvider).ToArray();
 }