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?
4 Answers
-
var activity = Titanium.Android.currentActivity;
activity.finish(); -
I too have the same problem can anyone help me?
-
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.
-
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);