gpt4 book ai didi

java - 在 Android 中禁用短信和电子邮件通知

转载 作者:行者123 更新时间:2023-11-30 09:48:19 25 4
gpt4 key购买 nike

在 Android 应用程序运行时,有什么方法(或非标准方法)可以禁用电子邮件和短信提醒/通知吗?我找到了一种使电话铃声静音的方法,但我想停止出现音频/振动警报。我见过一些可以将通知静音的就寝时钟应用程序,而且它们运行良好。

对如何编码有任何想法吗?

最佳答案

根据API docs :

AudioManager aM = getSystemService(Context.AUDIO_SERVICE);
aM.setRingerMode(AudioManager.RINGER_MODE_SILENT);
aM.setVibrateSetting (AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF)

public void setRingerMode (int ringerMode)

Since: API Level 1

Sets the ringer mode.

Silent mode will mute the volume and will not vibrate. Vibrate mode will mute the volume and vibrate. Normal mode will be audible and may vibrate according to user settings.

Parameters

ringerMode The ringer mode, one of RINGER_MODE_NORMAL, RINGER_MODE_SILENT, or RINGER_MODE_VIBRATE.


public void setVibrateSetting (int vibrateType, int vibrateSetting)

Since: API Level 1

Sets the setting for when the vibrate type should vibrate.

This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.

Parameters

vibrateType The type of vibrate. One of VIBRATE_TYPE_NOTIFICATION or VIBRATE_TYPE_RINGER.

vibrateSetting The vibrate setting, one of VIBRATE_SETTING_ON, VIBRATE_SETTING_OFF, or VIBRATE_SETTING_ONLY_SILENT.

关于java - 在 Android 中禁用短信和电子邮件通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6294399/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com