Skip to content

Instantly share code, notes, and snippets.

@kristjanmik
Last active July 25, 2016 14:58
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kristjanmik/aefc77b5b05e792ecdd2 to your computer and use it in GitHub Desktop.
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
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(){
})
@lowb1rd
Copy link

lowb1rd commented Jun 21, 2016

Isn't that basically the same as the window's FOCUS and BLUR events?

@shivagunasehkaran
Copy link

Actually, I need this for pushnotification count updating thing for Background and Foreground Its works fine. Thanks :)

@arildojr
Copy link

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