Android:铃声模式更改为静音并不会停止手机振动
当有来电时,我尝试使用以下代码行将手机的铃声模式更改为 RINGER_MODE_SILENT。
AudioManager am = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
当手机停止响铃时,它会继续振动,尽管 RINGER_MODE_SILENT 表示它也应该停止振动。
我正在使用 SDK 1.6
更新:
由于我还没有找到解决方案,我尝试手动停用振动设置。
am.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF );
但这也并不能阻止来电时手机振动。
有什么想法吗?
更新2:
今天我尝试通过振动对象取消振动来解决该问题。
Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vib.cancel();
再次,没有成功。现在我已经没有想法了,我问自己是否有可能完全停止振动。
更新3:
当我重读Vibrator 类的文档。文档说:
“如果您的进程退出,任何振动 你一开始就会停止。”
在我看来,振动似乎与启动它的进程相关联,并且无法从另一个进程访问。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
抱歉,这是电话应用程序中的一个已知错误;它当前不监听
AudioManager.RINGER_MODE_CHANGED_ACTION
广播(这会告诉它停止铃声和振动)。我建议在 b.android.com 提交错误。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.您是否尝试过权限MODIFY_AUDIO_SETTINGS? SDK 表示:允许应用程序修改全局音频设置。
Have you tried permission MODIFY_AUDIO_SETTINGS? SDK says: Allows an application to modify global audio settings.
我也很难关闭此功能。
我使用了
AudioManager
setVibrateSetting()
,插入AudioManager.VIBRATE_TYPE_NOTIFICATION
和 0,但收到短信时它仍然振动。我想知道现在是否有办法完全覆盖此功能。
我认为 Vibrator 的
cancel()
方法适用于当前正在进行的振动。I too am having trouble turning this feature off.
I have used
AudioManager
setVibrateSetting()
, chucking inAudioManager.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.