为什么我的应用会切换到普通的铃声模式,但没有播放铃声?
当我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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论