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); }
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); }
static Sensors() { App.CameToForeground += () => { if (Accelerometer.ShouldDetectShaking) { Thread.Pool.RunActionOnNewThread(RegisterShakeHandler); } }; App.WentIntoBackground += () => { if (Accelerometer.ShouldDetectShaking) { UIRuntime.GetService <SensorManager>(Context.SensorService).UnregisterListener(ShakeRecognizer); } }; }
static Vibrator CreateVibrator() => UIRuntime.GetService <Vibrator>(Context.VibratorService);
internal static void Init() { Manager = UIRuntime.GetService <LocationManager>(Context.LocationService); Providers = Manager.GetProviders(enabledOnly: false).Where(s => s != LocationManager.PassiveProvider).ToArray(); }