Last active
July 25, 2016 14:58
-
-
Save kristjanmik/aefc77b5b05e792ecdd2 to your computer and use it in GitHub Desktop.
A proper way to handle pause and resume event in titanium for android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Ti.UI.createWindow({}); | |
win.addEventListener("open", function(e) { | |
win.activity.addEventListener("resume", function() { | |
Ti.App.fireEvent('resume') | |
}); | |
//Notice the pause event | |
win.activity.addEventListener("pause", function() { | |
Ti.App.fireEvent('paused') | |
}); | |
}); | |
//Now works perfectly | |
Ti.App.addEventListener('resume',function(){ | |
}) | |
Ti.App.addEventListener('paused',function(){ | |
}) |
really helpful (Y)
Hi, thanks for the snippet.
Let me just ask a question: what if I open a new window from win? In that case, the paused
event would be raised, but it's not the case. How can I discern from this case and the proper one?
Isn't that basically the same as the window's FOCUS and BLUR events?
Actually, I need this for pushnotification count updating thing for Background and Foreground Its works fine. Thanks :)
https://github.com/benbahrenburg/benCoding.Android.Tools
isInForeground() method solved my problem.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is really useful, thanks