Titanium.App.exit for Android
I'm developing a simple little app for my Android phone.
My BACK button doesn't work as it should (it SHOULD exit the app when I am on the main menu, wich i've put on app.js) but it only zapps between former open windows I've been on within the app. The ideal solution would be to get this button to work, but how?
The other solution I thought of, was the Titanium.App.exit wich unfortunately seems only to work for Desktop apps?
I want to put this "exit button" in an Android.OptionMenu in an eventlistener.
Anyone able to help me, either to get the Back button to work, or some other way to exit my app? Please?
/j
3 Answers
-
Use finish() method for current activity:
var activity = Titanium.Android.currentActivity; activity.finish();
Works for 1.5+: http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android.Activity-object.html
-
In the first window you create in app.js add this property:
exitOnClose: true
-
Joar
You need to use exitOnClose and a property to make the window heavyweight, such as navBarHidden. For example:
var window = Ti.UI.createWindow({ backgroundColor: '#cccccc', exitOnClose: true, navBarHidden: false });