Reputation: 274
My Windows Phone application runs under the lock screen. If I keep my application in foreground and keep the screen locked for some time, I get a message "Resuming..." on a black screen on unlocking the phone. This message displays for a while and my application deactivates after that. I then need to relaunch the application. This issue is observed sometimes only. In other cases, the application remains in foreground when phone is unlocked.
Please help me if anyone has come across a similar issue and knows the solution for the same.
Upvotes: 0
Views: 237
Reputation: 29792
If you want to run App under Lock screen then disable ApplicationIdleDetection - there are many post at this site where you can find more information - for example.
@topher91 is right - without disabled IdleDetection your App goes to Dormant (or Tombstoned) state when the lock screen Activates, and he pointed out where you can save your variables/resources to bring them back whet App is Activeted.
Upvotes: 1
Reputation: 222
An app is sent to the background "Dormant" when another app is launch so your app is sent to the background. This can also happen when the app is consuming to many resources whilst running under the lockscreen so to conserve battery the os deactivates the app.
When you resume the app you must has have a dependency or object which is no longer valid cause the app to crash. You should be able to look at the at the stacktrace to identify which object is causing the problem.
You can change the what happens when the app resumes in the to prevent this problem
App.xml.cs
which contains 4 methods which enables you to change the start, pause, resume, close behaviour.
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)
{
}
Upvotes: 2