如何在 Android 媒体播放器中处理来电?
我已经在android中创建了一个媒体播放器,一切正常,除了当我接到电话时播放器继续播放。为了处理呼叫,我认为我们应该使用广播接收器并监听电话状态。但作为一个初学者,我无法弄清楚如何实现它?。请帮助
,谢谢
Possible Duplicate:
Android 2.1+ Pause for incoming/outgoing call, resume when done
I have created a mediaplayer in android and everything works fine except that the player keeps on playing when i receive a call. To handle a call i think we should use broadcast receiver and listen to phone state. But being a beginner i couldnt figure out how to implement it?.Please help
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要设置 PhoneStateListener,特别注意“onCallStateChanged”方法,并根据呼叫状态向媒体播放器发送适当的命令(振铃时暂停,如果需要的话挂断后恢复,等等)。
You'll want to set up PhoneStateListener, specifically paying attention to "onCallStateChanged method, and send commands to the media player as appropriate based on call state (pause when ringing, resume after hangup if so desired, etc).