Reputation: 6772
Current scenario stands like this:
I need to achieve following:
Questions:
Thank you
Upvotes: 1
Views: 1103
Reputation: 2256
there is no way to detect when an app got closed by the task switcher or system. Usually apps keep tombstoned until they get either reactivated or killed. You have to do all the clean-up work in the Application_Closing
and Application_Deactivated
events.
This has one simple reason: When an application lies in the background it is freezed and cannot execute code. Whenever the user or the system kills it (to get more memory for example) the app and all its data get completely wiped out of the memory. Without notifying your app and without giving it the chance to gain performance (which would be counterproductive).
So you just have the chance to use the Application_Deactivated
event when the user tap the start button or another app is launched or the Application_Closing
event when the user closes the app via back button.
Read this if you need additional information about the Windows Phone 8 Application lifecycle.
Beside this a user would expect that the background audio is still running after he closes the application. A podcast for example should also play when I closed the podcast app. What kind of audio are you talking about? Maybe we can find a smart solution...
Upvotes: 1
Reputation: 1560
The only events you can react to are Closing and Deactivated. So here,you can call BackgroundAudioPlayer.Instance.Close() in "Application_Closing" event only.
Upvotes: 0