Why do I have to press back button twice to "minimize" Android app when hiding title bar?

You must Login before you can answer or comment on any questions.

Howdy, If I make an app like this, everything is peachy for Android:

Titanium.UI.BackgroundColor('#000');
 
var win = Titanium.UI.createWindow({
  backgroundColor:'#ff9900'
});
 
win.open();
When I hide the title bar for Android, things get funky when I do this:
Titanium.UI.BackgroundColor('#000');
 
var win = Titanium.UI.createWindow({
  backgroundColor:'#ff9900',
  navBarHidden:true,
  fullscreen:false
});
 
win.open();
When I hit the back button, a blank window with a title bar is shown and you have to hit the back button again to "minimize" the app. I've tried this with mixed results:
Titanium.UI.BackgroundColor('#000');
 
var win = Titanium.UI.createWindow({
  backgroundColor:'#ff9900',
  navBarHidden:true,
  fullscreen:false,
  exitOnClose:true
});
 
win.open();
That's OK for some apps, but I want my app to continue checking GPS on occasion and continue to bring up notifications as needed. exitOnClose would "kill" the app would it not?

Any thoughts on how I can get around the extra back button press while also hiding the title bar?

— asked 2 years ago by Christopher Stevens
1 Comment
  • I guess maybe the real question is, is there a way to minimize the app when pressing back instead of closing the window? Thanks for your patience as I work through this.

    — commented 2 years ago by Christopher Stevens

1 Answer

I would like to see this question answered as well. When I fire the android:back event in the first window in my Android window hierarchy, a blank white window is shown. Hitting back again closes the application.

Thanks, M

— answered 2 years ago by M J
answer permalink
2 Comments
  • Note that my question has more to do with 'minimizing' the Titanium application versus exiting it. I'm aware of the exitOnClose window property, however I would prefer to send the app to background (as Android apps typically do) and not have to reload the application the next time it is switched into.

    — commented 2 years ago by M J

  • Solved the issue by adding the following Kroll method to a custom Android module that we were already using:

    @Kroll.method
    public void sendAppToBackground() {
        Activity app = getTiContext().getActivity();
        app.moveTaskToBack(false);
    }
    Come on @Appcelerator, an action this simple really should be exposed to your framework's users by default!

    — commented 2 years ago by M J

Your Answer

Think you can help? Login to answer this question!