Search code examples
androidlistviewserviceandroid-activitymedia-player

when Mediaplayer is done, return to previous screen


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


Solution

  • 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.