I am currently working on an app that check for GPS data every X mins/seconds. I use the "pause" event to stop it while the app is in background and resume it with "resume" event. No problem there.
The problem is when you lock the device: it fires the pause event but won't resume on unlock. Is it a known bug? Is there another event I should know of?
Thanks!
Listen for the "resumed" (with a D at the end) event instead of "resume".
You will get "resumed" for app relaunch (along with the "resume" event), but also for unlock, dismiss of a notification, dismiss the multitasking bar, etc.
Related
I want to have logic that triggers right before my UWP process is exited or gracefully killed. Is there anything that may accomplish what I wish to do? Or is this impossible in the UWP environment?
I know there exists a trigger for "onSuspending", but I do not want to trigger on that, I want to trigger when the process is exited or gracefully killed. I am aware of the "confirmAppClose" capability and "CloseRequested", but based on research, that seems to only be applicable for the "X" close button. I have a background task with no UI so there is not "X" button visible to trigger it. I am aware of "CoreApplication.Exiting" event but it seems like that won't work either based on what I've read.
I have to say that currently, there is no other ways for UWP to handle the app close request than the CloseRequested event. So it is impossible to get notified when the app is forcibly closed. As you've already known, the CloseRequested event only works when user click the "X" Button.
If I close my app with the back-button, the event Application_Closing is raised and the code is executing.
When I close my app in the list with active apps, no event is raised...
I really need an event for this.
Does anyone know a solution?
There is no event to detect when your app is terminating from the app list. When your app goes to background it will be tombstoned.
You can react on this with the Application_Deactivated event. So you should handle both events Application_Deactivated and Application_Closing.
Learn more about the app's lifecycle here.
I got a problem with jPlayer.
When the page loaded, the player plays automatically but it doesn't trigger "play" event.
Only when I click on pause button and click on play button again, the event is triggered.
Is that a bug of jPlayer?
hard to say since you don't mention which browser you are experiencing this in but my experience is that it is safer to rely on the 'playing' event rather than the 'play' event. Ideally the 'play' event is to be fired as soon as you call jPlayer('play') and 'playing' then is fired once the actual playback starts (i.e. after initial buffering etc). What I've seen this works fine in Safari but does not work in Chrome, in Chrome the two events are both fired when content starts to play.
I need to check for unsaved data when a packaged app is closed (using the close button at the bottom of the screen and then pressing the X that is top left when the app appears reduced size).
I've managed to add an event listener for the low battery condition and this works as expected. But looking at https://developer.mozilla.org/en-US/docs/Web/Events I can't decide which event is correct for closing an app.
The obvious name -- close -- seems to be something to do with web sockets.
mozbrowserclose seems to be triggered when closing by the app's software.
XUL close "the user presses the close button" seems like the appropriate one, but when trying
window.addEventListener("close", function( event )
{
window.alert("closing");
}, false);
the app closes without triggering the alert.
DOMWindowClose seems to be specific for close by window.close in software
mozbrowserclose seems to be specific to iframes
So ... does anybody know the correct event to trap ?
Phone is ZTE Open C with FFOS 1.3.
It looks like this is a bug -- https://bugzilla.mozilla.org/show_bug.cgi?id=996754 "User-terminated apps do not receive 'beforeunload' event"
I'm seeing some unexpected things happening in the emulator.
When debugging and starting the app for the first time, the Application_Launching fires just fine. When clicking the start button, the Application_Deactivated event fires fine. When click the back button, the Application_Activated event fires fine.
If I click the start button then go to my apps and launch my app, no events are fired. I would assume either the Application_Launching or Application_Activated would fire when the app is launched every time, just a different event depending on how the app got there.
Is this an issue with the emulator or do I have the wrong assumptions here?
Well, the events get fired right. What you missed is that debugger get dettached when you are launching "new instance" of your app. ;)