问题描述
我实现了PhoneStateListener,该方法如何在被呼叫时停止音频并在完成后重新启动.当我通过finish()退出我的应用程序时,PhoneStateListener似乎仍然处于活动状态.通话结束后,音乐开始播放.即使我在onDestroy()中设置了listener = null,它仍然可以正常工作...
I implemented a PhoneStateListener how stops audio if you are called and starts it again after you finished.When i exit my app by finish() the PhoneStateListener seems to be still active. After finishing a call the music starts to play.Even if I set the listener=null in onDestroy() it keeps working...
推荐答案
在listen()的文档rel ="nofollow"> TelephonyManager
:
Quoting the documentation for listen()
on TelephonyManager
:
您必须在活动超出范围(例如在onPause()
或onDestroy()
中)之前执行此操作.
You must do this before your activity goes out of scope, such as in onPause()
or onDestroy()
.
这篇关于PhoneStateListener()尚未完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!