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(){ | |
}) |
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
Actually, I need this for pushnotification count updating thing for Background and Foreground Its works fine. Thanks :)