I am working on Windows Phone. When My application deactivated and goes into the background, I want to detect the application deactivation on OnNavigatedFrom event so that I can implement some logic if application goes into the background. How can I do this?????
Asked
Active
Viewed 988 times
3 Answers
1
I found a solution myself. Attach handler to PhoneApplicationService.Current.Deactivated event on page from which you are navigated.

atul
- 135
- 1
- 2
- 8
1
You can Save the time wehn it deactivates from APP Events or page events and store that in IsolatedStorage then retrieve data wen your app reactivated ( OnNavigatedTo).

Ahmed Emad
- 550
- 2
- 7
- 25
0
Use the following methods (found in the App.xaml.cs file) to execute logic when the app is activated or deactivated:
// Code to execute when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
}
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
}
// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
}
// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
}

PmanAce
- 4,000
- 2
- 24
- 29