Titanium Community Questions & Answer Archive

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

How can I exit my Application via a button?

Hi,when my app finished its job,i want to exit it via a button just like

var dialog_success = Titanium.UI.createOptionDialog({
    options: ['exit', 'cancel'],
    title: 'click exit to quit'
});
dialog_success.addEventListener('click', function(e){
    if (e.index == 0) {
        //window.close() seems does not work,what can i do here?
    }
});

I already set exitOnClose=true

var window = Titanium.UI.createWindow({
    title: "how can i clost myself?",
    backgroundColor: 'black',
    exitOnClose:true
});

can anyone give me some advice?

— asked September 10th 2010 by Wen Bin
  • application
  • exit
  • quit
  • window
0 Comments

4 Answers

  • var activity = Titanium.Android.currentActivity;
    activity.finish();

    — answered January 19th 2013 by sergio ibanez
    permalink
    1 Comment
    • Thanks :) It Worked fine for me , wondering why some one voted negative O_o

      — commented May 22nd 2013 by Rezz Delavega
  • I too have the same problem can anyone help me?

    — answered December 30th 2010 by Lakshmanan Ponnusamy
    permalink
    0 Comments
  • Exiting the application using a button will never pass apple's approval process as it is against their approval rule. So don't do that.

    — answered January 30th 2011 by hasin hayder
    permalink
    1 Comment
    • Then how to close back end running process for my application? help me out.I am facing this problem on android device.

      — commented November 22nd 2011 by Fernan Delgado
  • make your window heavy,… either using modal or fullscreen attribute.
    this code worked for me.
    example.

    var win1 = Titanium.UI.createWindow({  
        title:'myWindow',
        exitOnClose:true,
        backgroundColor:'#fff',
        modal:true
    
    });
    
    
    
    
    var b6=Titanium.UI.createButton({
        title:'Exit',
        top:440,
        width:100
    });
    
    b6.addEventListener('click',function(){
        win1.close();
    });
    
    
    win1.add(b6);
    
    — answered January 30th 2011 by Awais Akhtar
    permalink
    1 Comment
    • My application is closed and navigate to home screen using setting both [exitOnClose:true; OR Titanium.Android.currentActivity.finish();] but at settings->manage application->running it showing my application icon running list at back end so how to resolve this issue?I want when my application is gets closed at a time i want to stop back end running process also.please help me out.

      — commented November 19th 2011 by Fernan Delgado
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.