开发者

Android: Ringer mode changed to silent doesn't stop the phone vibrating

开发者 https://www.devze.com 2022-12-27 06:24 出处:网络
I\'m trying to change the ringer mode of the phone to RINGER_MODE_SILENT when a call is incoming by using the following lines of code.

I'm trying to change the ringer mode of the phone to RINGER_MODE_SILENT when a call is incoming by using the following lines of code.

AudioManager am = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
am.setRingerMode(AudioManager.RINGER_MODE_SILENT);

While the phone stops ringing it continue to vibrate although the documentation of RINGER_MODE_SILENT says it should also stop vibrating.

I'm using the SDK 1.6

UPDATE:

As I didn't find a solution yet, I tried to deactivate the vibration settings manually.

am.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF );

But this also doesn't prevent the phone form vibrating when a call is incoming.

Any ideas?

UPDATE 2:

Today I tried to solve the problem by canceling the vibration via a Vibration object.

开发者_开发技巧Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vib.cancel();

Again, without success. Now I'm running out of ideas and asking myself if it is possible to stop the vibration at all.

UPDATE 3:

I've discovered another interesting fact when I've reread the documentation of the Vibrator class. The documentation says:

"If your process exits, any vibration you started with will stop."

This sounds to me as if the vibration is linked to the process that started it and cannot be accessed form another process.


Sorry, this is a known bug in the Phone app; it doesn't currently listen for AudioManager.RINGER_MODE_CHANGED_ACTION broadcasts (which would tell it to stop the ringer and vibration). I recommend filing a bug at b.android.com.


Have you tried permission MODIFY_AUDIO_SETTINGS? SDK says: Allows an application to modify global audio settings.


I too am having trouble turning this feature off.

I have used AudioManager setVibrateSetting(), chucking in AudioManager.VIBRATE_TYPE_NOTIFICATION and 0, but it still vibrates when a text message is received.

I'm wondering if there is a way to completely override this feature now.

I think Vibrator's cancel() method is for a vibration that is currently in progress.

0

精彩评论

暂无评论...
验证码 换一张
取 消