When we deactivate a WP app, it can be tombstoned and terminated later by the OS. I need to save some unsaved app data to a persistent storage when the process is terminated, but not before this. Obviously, the Deactivated event cannot be used for this purpose as it is raised immediately when an app is moved to the background; the Close event is also not the event we need as it si not raised when the app process is terminated by the OS. Is there a special Windows Phone app event for that, something like Application_Terminated?
WinPhone app event to react on app process termination
98 Views Asked by TecMan At
2
There are 2 best solutions below
1
aruntalkstech
On
There is no such event. You should save your state on Deactivated so that if the application is removed from memory (tombstoned) you can set yourself up again upon reactivation. If your problem is figuring out whether or not you need to restore state on Activated, check out the ActivatedEventArgs.IsApplicationInstancePreserved flag (http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.shell.activatedeventargs.isapplicationinstancepreserved(v=vs.105).aspx). This flag tells you whether your app was tombstoned. If it wasn't, you can throw away the old state or overwrite it the next time you are deactivated.
Related Questions in WINDOWS-PHONE
- DEP0001: Unexpected Error: SmartDeviceException - Incompatible version of the RPC stub. [0x80131500] during UWP app deployment to Windows phone
- Chilkat mail UWP on Windows 10 Phone gives Class not registered error
- How to fix the issue "UWP app stopped after navigation"?
- How to set Grid.Background to MediaPlayer in UWP?
- Unable to publish UWP package update with the `invalid package identity/family name` error
- Lumia 640 LTE edge explorer - javascript $ is not defined
- iOS / Windows Store App: can I know whether my other app installed on this device/user account?
- Get app purchase date for Windows Phone 8.1 and Windows 8.1 applications
- Complicated background work in UWP, is it real?
- How to export React native code for windows platform
- Get Host File on my windows phone
- UWP Windows Phone detect type of USB connection
- Override default call interface
- UWP: Control won't fit to the available view area of my Grid cell
- Angular 4, Phonegap icons Windows Phone 10
Related Questions in TERMINATION
- SIGTERM signal logs for Go application in EKS
- Termination checking of a function fails in Agda
- Proving non-linear traversal terminates in Dafny
- Idris prove termination of proof without assert_smaller
- How to know spring boot application run stopped due to hard error or it just completed normally
- Why Apache Traffic Server does not cache https content even though SSL termination has been setup?
- Debugging a Python/Django app using Visual Studio Code VCS problem with the Terminate or stop button after a breakpoint but execution continues
- TLS termination of Redis traffic in Istio
- Can node affinity cause pod eviction?
- OpenAI gym CarRacing-v2 episode termination
- Finding if the lcm of a list is in the set 3^d
- Function termination proof in Isabelle
- Why does my service not stop when the app is terminated?
- Gracefull termination of multiprocessing.Pool.map function using KeyboardInterrupt
- Pyomo - MindtPy : Why is it that status=ok and termination_condition=feasible for an infeasible problem?
Related Questions in APPLICATION-LIFECYCLE
- On Bean destroy invoking Pre-Destroy method or Listening to ContextStopped or ContextClossed event is not working
- Application is reboot when revoking application permissions
- Angular2: Are dynamically created injectors (created via Injector.create(...)) ever destroyed?
- App Foreground callback coming late in IOS swift
- Why my app gets fired immediately after entering background mode?
- signalr method not being triggered in onSleep event xamarin.forms
- How to automatically remove a Kubernetes pod when it does not receive TCP/UDP connections for a certain period of time?
- How do "Suspended" and "Not Running" states look like for the user?
- Animation library is giving me this error about lifecycle state
- Flutter: Common class to whole check whole app lifecycle
- LifecycleObserver.onCreate is not called when Application is created
- WindowsAppSDK doesnt have ProtocolActivatedEventArgs
- How can I detect If my android application is Destroyed/Paused/Stopped without fail?
- Why is (and how to fix) my Android application triggering an onCreate (ON_CREATE) when removed from memory?
- Lifecycle @OnLifecycleEvent() is deprecated, and you should use LifecycleEventObserver or DefaultLifecycleObserver
Related Questions in TOMBSTONING
- MVVMCross 6.4.3 Restore is not working as expected
- Cassandra Read time out on performing query in order to mass delete
- Caliburn.Micro restores ViewModel after navigating back
- How to get the object reference of backstack pages
- Restoring static properties of a class inside a portable class library, after tombstoning in windows phone 8.1
- security exception thrown while testing WP8 app Life cycle?
- PhoneApplicationService.Current.State vs IsolatedStorageSettings windows phone
- Get screen height in WP8 Silverlight app on page initialization after tombstoning
- Suspend/Resume/Tombstone simulation in Windows Phone 8.1 Emulator
- Windows Phone 8 prevent the app from ever being re-activated and restart on next launch
- Azure Mobile Service, Monogame, Windows Phone 8 and resuming a tombstoned app
- How fast WP7 would close app on deactivation via Windows button?
- NavigationContext.QueryString isn't cleared after tombstoning in WP8 Silverlight page app
- WinPhone app event to react on app process termination
- How to save a coordinate list after app is tombstoned?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The problem is that the operating system only tombstones your app when it is under severe resource pressure. At the time it is not practical to wake up the app and run app code because it might risk whatever is currently in the foreground. This limitation exists on all modern mobile operating systems (Android, IOS included). This is just the cost of operating in a battery/resource friendly environment.
Having said that, it sounds like your backing store does not disambiguate between data the user "saved" and data that is just being cached until the user can finish the transaction. It would be useful to build the idea in. Think of it the way some of the smarter web sites on the internet now work. You can navigate away while you were in the middle of entering data and when you come back the site presents you with the partially filled form. The site understands that you weren't "done" but it respects the fact that you had provided some of the information you'd need to get "done".
What I'm saying here is that the problem is easily fixed by understanding and accommodating the way your users are likely to use the app. Thinking of your app like a web site (at least in this context) helps out things into perspective. Sorry about the longish answer. I hope it helps :)