Note that there are some explanatory texts on larger screens.

plurals
  1. POVibrate setting not turning off on receiving incoming call - Android
    text
    copied!<p>I want to turn off device vibrate setting when a call comes. I have implemented a BroadcastReceiver for this feature which performs the action on receiving <code>PHONE_STATE</code> broadcast. The problem is that I am not able to turn off vibrations at all. I have tried the following:</p> <pre><code>AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF); </code></pre> <p>or</p> <pre><code>Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vib.cancel(); </code></pre> <p>The first approach seems ideal to me. It even works for turning "on" the vibrations when a call is received. But, I am not able turn them "off" in this scenario.</p> <p>Has anybody tried this?</p> <p>Edit: I checked Android's Phone app code. Following code is present in <a href="http://source-android.frandroid.com/packages/apps/Phone/src/com/android/phone/Ringer.java" rel="nofollow">Ringer.java</a>:</p> <pre><code>if (shouldVibrate() &amp;&amp; mVibratorThread == null) { mContinueVibrating = true; mVibratorThread = new VibratorThread(); mVibratorThread.start(); } </code></pre> <p>A thread is started initially by Phone app which vibrates the phone. When I change the vibrate setting to off this check is skipped but the already started thread keeps on running.</p> <p>This also explains how vibrations can be turned on when an incoming call comes. In that case, the thread is not running initially. Then, it is started when I turn on the vibrate setting. I don't think there is any solution to the problem without changing the Phone app.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload