0

I am working on a settings Activity, and I need to enable or disable vibration/tone. I need to learn how to do these two functionalities in my app. I am also providing a snapshot of the setting Activity. I have tried this code for vibration but I do not know how to use this code in check box.

Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);  
vib.vibrate(500);
Toast.makeText(this, "vib started", Toast.LENGTH_LONG).show();
Kevin Coppock
  • 131,356
  • 43
  • 258
  • 273

1 Answers1

0

First you have to store checkbox value in SharedPreference see this link Here

Then check this store value using condition and execute that vibrate and ring code.

  AudioManager audioManager = (AudioManager) this.getApplicationContext()
            .getSystemService(Context.AUDIO_SERVICE);

   audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
Community
  • 1
  • 1
Arpit Patel
  • 9,047
  • 5
  • 60
  • 72