为什么我的应用会切换到普通的铃声模式,但没有播放铃声?

发布于 2025-01-25 01:25:18 字数 741 浏览 4 评论 0原文

当我traid设置ringer_mode_normal时,应用程序会更改但听起来不变时,它会更改屏幕顶部的图标,但不会发出任何声音。 这个想法是,呼叫进入时,它会切换到正常的声音模式。

class PhoneStateListenerClass @Inject constructor(
       @ApplicationContext context: Context,): PhoneStateListener() {
val audiomanager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
 override fun onCallStateChanged(state: Int, incomingNumber: String) {
    if(state==TelephonyManager.CALL_STATE_RINGING){
        audiomanager.ringerMode=AudioManager.RINGER_MODE_NORMAL //change the icon but dont sound the ringtone
    }
    if (state==TelephonyManager.CALL_STATE_IDLE){
       audiomanager.ringerMode=AudioManager.RINGER_MODE_VIBRATE
    }
    super.onCallStateChanged(state, incomingNumber)
}

When i traid to set the RINGER_MODE_NORMAL the application changes but does not sound, it changes the icon at the top of the screen but it does not make any sound.
The idea is that it switches to normal sound mode when a call is coming in.

class PhoneStateListenerClass @Inject constructor(
       @ApplicationContext context: Context,): PhoneStateListener() {
val audiomanager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
 override fun onCallStateChanged(state: Int, incomingNumber: String) {
    if(state==TelephonyManager.CALL_STATE_RINGING){
        audiomanager.ringerMode=AudioManager.RINGER_MODE_NORMAL //change the icon but dont sound the ringtone
    }
    if (state==TelephonyManager.CALL_STATE_IDLE){
       audiomanager.ringerMode=AudioManager.RINGER_MODE_VIBRATE
    }
    super.onCallStateChanged(state, incomingNumber)
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文