[TIMOB-5041] Android: Activity related events fire only once for tabgroup activity
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2011-09-12T13:36:25.000+0000 |
Affected Version/s | Release 1.7.2 |
Fix Version/s | n/a |
Components | Android |
Labels | android, enterprise |
Reporter | Anirudh Nagesh |
Assignee | Don Thorp |
Created | 2011-08-17T18:07:23.000+0000 |
Updated | 2017-03-23T21:37:29.000+0000 |
Description
The activity related events fire only once on tabgroup activity, but works fine with a heavyweight window.
The Sample code is below.
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
window:win2
});
var label2 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 2',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win2.add(label2);
//
// add tabs
//
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
// open tab group
tabGroup.open();
Ti.Android.currentActivity.addEventListener('pause', function(e){
Ti.API.info('changeState App is pausing');
});
Ti.Android.currentActivity.addEventListener('resume', function(e){
Ti.API.info('changeState App is resuming');
});
Check out the workaround on [TIMOB-4121] for an explanation of how to get around what you are seeing.
The example in that ticket relies on multi-context application (url parameter in the createWindow call), we have a big app that suffered major stability issues until we were advised by you guys to convert it to a single-context app - that helped a lot, but set us back weeks behind our schedule. we cannot convert it back to multi-context because we don't have the time and it will bring instability back to the app. we need another workaround even if it is only temporary and even if it means a private fork of the framework...we need to ship the product ASAP.
BTW, all we need is to repsond to when the user presses the HOME key and send the app to the background...we need to cleanup and also when the app is resumed, we need to reinitiate. We don't need control per tab...right now we get a single event and further pause/resumed are not triggered.
The activity is in relationship with the window. This code works as expected: (assuming this is a single context application)
Code:
Conclusion:
- Make the windows "fullscreen: false" - And set the event listener to the window's activityWorking sample code provided. This is not a bug.
This example only works if the window is part of a tabGroup. Otherwise, if you have a heavyweight window that is not part of a tabGroup, if you try to do something with the activity of the heavyweight window, such as win.activity.addEventListener('pause', function () { Ti.API.info('pause') }); you get "Uncaught TypeError: Object #
Closing ticket as invalid with reference to the previous comments.