Created
May 31, 2011 15:42
-
-
Save jonalter/1000709 to your computer and use it in GitHub Desktop.
Android detect app closed with home button
This file contains hidden or 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
| Titanium.UI.setBackgroundColor('#000'); | |
| var tabGroup = Titanium.UI.createTabGroup(); | |
| var win1 = Titanium.UI.createWindow({ | |
| title:'Tab 1', | |
| url:'main.js' | |
| }); | |
| var tab1 = Titanium.UI.createTab({ | |
| icon:'KS_nav_views.png', | |
| title:'Tab 1', | |
| window:win1 | |
| }); | |
| var win2 = Titanium.UI.createWindow({ | |
| title:'Tab 2', | |
| url:'main2.js' | |
| }); | |
| var tab2 = Titanium.UI.createTab({ | |
| icon:'KS_nav_ui.png', | |
| title:'Tab 2', | |
| window:win2 | |
| }); | |
| tabGroup.addTab(tab1); | |
| tabGroup.addTab(tab2); | |
| tabGroup.open(); | |
| count = 0; | |
| Ti.App.addEventListener('pause', function(){ | |
| count-=1; | |
| Ti.API.info('Pause Event '+count); | |
| if(count<=0){ | |
| // whatever you put here will fire when the app closes | |
| Ti.Android.currentActivity.finish(); | |
| } | |
| }); | |
| Ti.App.addEventListener('resume', function(){ | |
| count+=1; | |
| Ti.API.info('Resume Event '+count); | |
| }); |
This file contains hidden or 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.currentWindow; | |
| win.backgroundColor = 'red'; | |
| Ti.Android.currentActivity.addEventListener('pause', function(e){ | |
| setTimeout(function(){Ti.App.fireEvent('pause');},500); | |
| }); | |
| Ti.Android.currentActivity.addEventListener('resume', function(e){ | |
| Ti.App.fireEvent('resume'); | |
| }); |
This file contains hidden or 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.currentWindow; | |
| Ti.UI.currentWindow.backgroundColor = 'blue'; | |
| Ti.Android.currentActivity.addEventListener('pause', function(e){ | |
| setTimeout(function(){Ti.App.fireEvent('pause');},500); | |
| }); | |
| Ti.Android.currentActivity.addEventListener('resume', function(e){ | |
| Ti.App.fireEvent('resume'); | |
| }); |
this does not works
Please give me some hint on this,I really need help on this.
In my app I want to display one screen with password protection,when app goes in background and again in foreground then this password screen comes in picture and when user enter right password he is on screen from where app goes in background.
Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't work