Android:铃声模式更改为静音并不会停止手机振动

发布于 2024-08-28 17:21:10 字数 1161 浏览 3 评论 0原文

当有来电时,我尝试使用以下代码行将手机的铃声模式更改为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱*していゐ 2024-09-04 17:21:10

抱歉,这是电话应用程序中的一个已知错误;它当前不监听 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.

街角卖回忆 2024-09-04 17:21:10

您是否尝试过权限MODIFY_AUDIO_SETTINGS? SDK 表示:允许应用程序修改全局音频设置

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

倾`听者〃 2024-09-04 17:21:10

我也很难关闭此功能。

我使用了 AudioManager setVibrateSetting(),插入 AudioManager.VIBRATE_TYPE_NOTIFICATION 和 0,但收到短信时它仍然振动。

我想知道现在是否有办法完全覆盖此功能。

我认为 Vibrator 的 cancel() 方法适用于当前正在进行的振动。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文