Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

App closes when you tap the Back button, it should go back

Android/Windows/SDK 1.4

My app closes when you press the back button–the curvy-left-arrow on the phone/emulator (not a button defined w/in my app). I want it go back to the previously opened window.

app.js - switcher that opens one of a few windows based on prior use of the app

mainwin.js - defines & opens the main window of the application

profile.js - defines a window listing profiles created by the user

A button tap in mainwin.js opens profile.js with statements like this:

Titanium.include('profile.js');
profilewin.open();

With the profile window open, if you tap the back button, the app should go back to the main window (defined in mainwin.js) but instead it closes.

I see the exitOnClose: true property, which I've set for only the window definition in mainwin.js. If I set that property to false, how do I specify which window/file would be opened?

Tim

— asked September 7th 2010 by Tim Poulsen
  • android
  • window
0 Comments

1 Answer

  • Accepted Answer

    You may want to try something like this on the current window

    win.addEventListener('android:back', function() {
        win.close();
    });
    

    Just note the window has to be a "heavyweight" window. (window called with either fullscreen, modal, or tabBarHidden - but they can be false)

    — answered September 7th 2010 by John Veldboom
    permalink
    1 Comment
    • Thanks John! That did it. I had to use fullscreen:false with the window … well, it worked with any of the properties you listed set true or false. But, with any but fullscreen:false, the top of the title area was cut off as if I had set top:-10 or so.

      Thanks!

      — commented September 7th 2010 by Tim Poulsen
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.