Hi i am working on android application development.I am using Titanium studio for development. I create a simple application.I want to capture the device back button event in my application because I don't want to user android default tabs in titanium.I am creating my own tabs.I tried following code :
:list.js
var expt = Titanium.UI.currentWindow;
expt.addEventListener('android:back', function (e)
{
Ti.App.fireEvent('expt_back_event');
});
:app.js
Ti.App.addEventListener('expt_back_event',function(e)
{
alert('hiiii in side event listener');
});
But its not working instead of giving pop-up it closed my application which I don't want. Is there any way to obtain this result.
You have to cancel the bubble of the event.
mainWindow.addEventListener('android:back', function(e) {
e.cancelBubble = true;
Ti.App.fireEvent('android_back_button');
});