Event for iPhone Lock and Unlock?
Hello,
Having a great time with 1.0, but I haven't been able to find a window event for when the iPhone is locked or unlocked. I hoped blur and focus would fire, but they don't seem to be.
Is there another event I'm missing?
I ask because I have a timer running that does fine when the app is open. But with the app running, if the iPhone is locked, when I unlock it, the timer is way behind. My guess is the iPhone slows down its CPU while locked and it's messing up my timer.
I think I could deal with it there were lock / unlock events.
Thanks for any help!
Steve
4 Answers
-
Hi guys,
It works but the 'pause' event is actually executed when we re-open the app (just before the 'resume' event)
You can check that in kitechen sink, you can see that it goes from "App has resumed" to "App has been paused" to "App has resumed" only when we re-open the app
I'm looking for a way to open a black view when 'pausing' the app, it does not actually work with this 'pause' event
Any advices?
Thanks guys!
-
I was facing the same issue and came up with the following work around. I created two variables one for the background state and one for the locked state and I assign them both as false through the pause event. In the subsequent resume event I change only the background variable to true and keep the locked variable to false and then in the resumed event (that fires after the resume event) I assigned the locked variable to true and then check if both are true which is the case of the app resuming from the background or if only the second (locked) is true which is the case of resuming from lock.
-
Woohoo! Found it in Kitchen Sink. It's in the "app_events.js" example (and pasted below). It's the pause and resume event for an App.
Also, please disregard my guess above about the CPU slowing down. Clearly, pause and resume is what's going on.
Titanium.App.addEventListener('pause',function(e) { paused = true; label.text = "App has been paused"; }); Titanium.App.addEventListener('resume',function(e) { if (paused) { label.text = "App has resumed"; } else { label.text = "App has resumed (w/o pause)"; } });
-
you can unlock your iPhone now easily with Unlock IMEI tool which is developed with the latest technologies and so unlocks your iPhone's IMEI just in few minutes without effecting any other application.