public HapticFeedback_Android() { try { am = (AudioManager)global::Android.App.Application.Context.GetSystemService (Context.AudioService); } catch (Exception ex) { try { var msg = LogMessage.FromException (ex, "Error initializing AudioManager! ", typeof(HapticFeedback_Android), "(constructor)"); PortableLogging.Instance.AppendMessages (new [] { msg }); } catch { } } try { v = (Vibrator)global::Android.App.Application.Context.GetSystemService (Context.VibratorService); } catch (Exception ex) { try { var msg = LogMessage.FromException (ex, "Error initializing Vibrator! ", typeof(HapticFeedback_Android), "(constructor)"); PortableLogging.Instance.AppendMessages (new [] { msg }); } catch { } } if (v != null && !v.HasVibrator) { try { var msg = LogMessage.FromException (new Exception (), "Android device does not have vibrator.", typeof(HapticFeedback_Android), "(constructor)"); PortableLogging.Instance.AppendMessages (new [] { msg }); } catch { } } }
public static void Initialize(Activity activity) { audioManager = (AudioManager)activity.GetSystemService(Context.AudioService); mediaPlayer = MediaPlayer.Create(activity.ApplicationContext, Resource.Raw.Message); notificationManager = (NotificationManager)activity.GetSystemService(Context.NotificationService); vibrator = (Vibrator)activity.GetSystemService(Context.VibratorService); //context = activity.ApplicationContext; context = activity; isAlertsEnabled = true; isProgressEnabled = true; }
public override void OnCreate () { base.OnCreate (); mLocationClient = new LocationClient(ApplicationContext); var option = new LocationClientOption (); option.SetIsNeedAddress (true); option.SetIsNeedLocationDescribe (true); mLocationClient.LocOption = option; mMyLocationListener = new MyLocationListener(handler, this); mLocationClient.RegisterLocationListener(mMyLocationListener); mVibrator =(Vibrator)ApplicationContext.GetSystemService(Service.VibratorService); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView (Resource.Layout.common_ui); CardboardView cardboardView = FindViewById<CardboardView> (Resource.Id.cardboard_view); cardboardView.SetRenderer (this); CardboardView = cardboardView; vibrator = (Vibrator)GetSystemService (Context.VibratorService); overlayView = FindViewById<CardboardOverlayView> (Resource.Id.overlay); overlayView.Show3DToast ("Pull the magnet\nwhen you find an object."); headView = new float[16]; game = new Game (this, headView); VolumeKeysMode = VolumeKeys.DisabledWhileInCardboard; }
/// <summary> /// Raised, when the activity is created. /// </summary> /// <param name="bundle">Bundle with cartridge and restore flag.</param> protected override void OnCreate (Bundle bundle) { // Set color schema for activity Main.SetTheme(this); base.OnCreate (bundle); // Load content of activity SetContentView (Resource.Layout.GameControllerScreen); // Get main layout to replace with fragments var layoutMain = FindViewById<LinearLayout> (Resource.Id.layoutMain); // Get data from intent Intent intent = this.Intent; string cartFilename = intent.GetStringExtra ("cartridge"); cartRestore = intent.GetBooleanExtra ("restore", false); // Check, if cartridge files exists, and if yes, create a new cartridge object if (File.Exists (cartFilename)) { cartridge = new Cartridge(cartFilename); } // If cartridge object don't exist, than close activity if (cartridge == null) Finish (); audioManager = (AudioManager)GetSystemService(Context.AudioService); vibrator = (Vibrator)GetSystemService(Context.VibratorService); // Create CheckLocation GameCheckLocation checkLocation = new GameCheckLocation(); // Show CheckLocation var ft = SupportFragmentManager.BeginTransaction (); ft.SetBreadCrumbTitle (cartridge.Name); ft.SetTransition (global::Android.Support.V4.App.FragmentTransaction.TransitNone); ft.Replace (Resource.Id.fragment, checkLocation); ft.Commit (); }
// entry point protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); clientId = GetClientId(); // gesture recognition internalRecognitionService = new GestureRecognitionService(new PhoneSensorSource(this)); externalRecognitionService = new GestureRecognitionService(new BluetoothSensorSource(this)); // register callbacks internalRecognitionService.RegisterListener(this); externalRecognitionService.RegisterListener(this); // start detecting gestures internalRecognitionService.StartClassificationMode(); externalRecognitionService.StartClassificationMode(); // keep light on and screen unlocked Window.AddFlags(WindowManagerFlags.KeepScreenOn); // get a vibrator service for feedback vibrator = (Vibrator) GetSystemService(VibratorService); // init screen layout SetContentView(Resource.Layout.Main); // init server connection InitializePresItServiceClient(); // register button click events var authenticateButton = FindViewById<Button>(Resource.Id.AuthenticateButton); authenticateButton.Click += async (sender, e) => { var scanner = new MobileBarcodeScanner(this); var result = await scanner.Scan(); if (result != null) new Thread(() => service.AuthenticateId(clientId, result.Text)).Start(); }; var nextSlideButton = FindViewById<Button>(Resource.Id.NextSlideButton); nextSlideButton.Click += (sender, e) => NextSlide(); var previousSlideButton = FindViewById<Button>(Resource.Id.PreviousSlideButton); previousSlideButton.Click += (sender, e) => PreviousSlide(); var pauseButton = FindViewById<Button>(Resource.Id.PauseButton); pauseButton.Click += (sender, e) => SwitchPause(); var trainingButton = FindViewById<Button>(Resource.Id.TrainingButton); trainingButton.Click += (sender, e) => { var text = trainingButton.Text; SetTraining(internalRecognitionService, ref text); trainingButton.Text = text; }; var externalTrainingButton = FindViewById<Button>(Resource.Id.ExternalTrainingButton); externalTrainingButton.Click += (sender, e) => { var text = externalTrainingButton.Text; SetTraining(externalRecognitionService, ref text); externalTrainingButton.Text = text; }; var trainingDataSaveButton = FindViewById<Button>(Resource.Id.TrainingDataSaveButton); trainingDataSaveButton.Click += (sender, e) => { var prefs = PreferenceManager.GetDefaultSharedPreferences(this); var editor = prefs.Edit(); editor.PutString("internalRecognitionService", internalRecognitionService.SerializeTrainingSet()); editor.PutString("externalRecognitionService", externalRecognitionService.SerializeTrainingSet()); editor.Commit(); }; var trainingDataLoadButton = FindViewById<Button>(Resource.Id.TrainingDataLoadButton); trainingDataLoadButton.Click += (sender, e) => { var prefs = PreferenceManager.GetDefaultSharedPreferences(this); if (!prefs.Contains("internalRecognitionService") || !prefs.Contains("externalRecognitionService")) return; internalRecognitionService.DeserializeTrainingSet(prefs.GetString("internalRecognitionService", "")); externalRecognitionService.DeserializeTrainingSet(prefs.GetString("externalRecognitionService", "")); }; }
public void gameFail() { RunOnUiThread (() => obrazekSmile.SetImageResource (Resource.Drawable.angry)); if (OptionsHodnoty.Vibrace) { mvibrator = (Vibrator)this.GetSystemService (Context.VibratorService); mvibrator.Vibrate (50); } Vysledek vysledek = new Vysledek (score, DateTime.Now.ToString ()); SeznamVysledku.seznam.Add (vysledek); SeznamVysledku.WriteToBinaryFile (); gameFailed = true; }
public void timeSucccess() { casovac.Stop (); foreach (ButtonItem bt in ButtonItem.seznamVisibleButtons) { bt.killThis (); } if (gameInterval >= 100 && gameInterval < 130) { RunOnUiThread (() => obrazekSmile.SetImageResource (Resource.Drawable.smile)); } if (gameInterval < 100) { RunOnUiThread (() => obrazekSmile.SetImageResource (Resource.Drawable.lol)); } if (OptionsHodnoty.Vibrace) { mvibrator = (Vibrator)this.GetSystemService (Context.VibratorService); mvibrator.Vibrate (10); } //System.Threading.Thread.Sleep (malaPausa); gameIntervalBase--; gameInterval = gameIntervalBase; casovac.Start (); }
public static void Init(Context root) { vibrator = (Vibrator)root.GetSystemService(Context.VibratorService); }
/** * Sets the view to our GvrView and initializes the transformation matrices we will use * to render our scene. */ protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); InitializeGvrView (); modelCube = new float [16]; camera = new float [16]; view = new float [16]; modelViewProjection = new float [16]; modelView = new float [16]; modelFloor = new float [16]; tempPosition = new float [4]; // Model first appears directly in front of user. modelPosition = new float [] { 0.0f, 0.0f, -MAX_MODEL_DISTANCE / 2.0f }; headRotation = new float [4]; headView = new float [16]; vibrator = (Vibrator) GetSystemService (Android.Content.Context.VibratorService); // Initialize 3D audio engine. gvrAudioEngine = new GvrAudioEngine (this, GvrAudioEngine.RenderingMode.BinauralHighQuality); }
void StopVibrating () { if (_vibrator != null) { _vibrator.Cancel (); _vibrator = null; } }
void StartVibrating () { if (_vibrator != null) { return; } _vibrator = (Vibrator) GetSystemService (Context.VibratorService); _vibrator.Vibrate (new long[] { 0, 1000, 1000 }, 0); }