Back button pressed does not work if used in code

I’m making a music player app, and I really wanted the app to work offline, but even though the sound was playing, the timer that I was using for the ‘elapsed timer’ slider didn’t work offline. So basically, I listened to music within the app for 7 seconds, then went to a different app. The sound would still continue playing, but when I entered the app again, it would still show 7 seconds, then 8. So, I decided to stop the music when Back Button Pressed. When I pressed the back button during Live Test, the sound paused but it didn’t close the app/go to the previous screen. What can I do to work around this? I need to either keep the slider running while in a different app or both close the app and pause the music when the back button is pressed. Also, lots of people like me press the home button instead of the back button, and I noticed that the Back Button Pressed code doesn’t work when I press the home button. Any ideas on making at least one thing work?

Thanks

1 Like