当 Mediaplayer 完成后,返回到上一个屏幕
我目前有一个带有 mediaplayer
的 service
。我想做的是,当没有更多歌曲可播放时,它只是返回到上一个屏幕,在本例中为 listview
。我添加了一个 finish();
但这似乎只是使应用程序出现 ANR。有什么建议吗?多谢
I currently have a service
with a mediaplayer
. What I would like to do is when there are no more songs to play, it simply returns to the previous screen, in this case a listview
. I added a finish();
but that just seems to ANR the app. Any suggestions? Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在服务上有一个事件调度程序,可以在没有其他内容可玩时向您的活动报告。或者当每首歌曲播放完毕时,听众会参与活动。然后,您可以告诉 Activity 执行您想要的任何操作,
finish()
或使用 Intent 转到新 Activity。You should have a event dispatcher on the service that can report back to your activity when there is nothing else to play. Or a listener on the activity when each song is done playing. Then you can tell the activity to do whatever you want,
finish()
or go to a new activity using intent.