bug: sometimes "setTimeout" doesn't work on Android
Hi,
Sometimes setTimeout works, sometimes setTimeout doesn't work on Android. Are there some conditions to make it work always?
Versions: Android APIs 2.1&2.2 and Titanium 1.6RC1
I tried the following simple code based on the app.js in the default project.
app.js:
Ti.include('test.js');
var tabGroup = Titanium.UI.createTabGroup();
setTimeout(function(){
Ti.API.info('setTimeout A OK!');
}, 3000);
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);
tabGroup.addTab(tab1);
tabGroup.open();
setTimeout(function(){
Ti.API.info('setTimeout B OK!');
}, 3000);
test.js:
setTimeout(function(){
Ti.API.info('setTimeout C OK!');
}, 3000);
(function(){
setTimeout(function(){
Ti.API.info('setTimeout D OK!');
}, 3000);
})();
The all 4 info logs (A, B, C, D) are printed on iPhone perfectly, but no log on Android.
Thank you.
3 Answers
-
I have the same problem…
edit: Seems to work you do it this way :
var f = function(){ } setTimeout(f,2000);
-
Same issue. Works great when declared using the 'var' syntax.
For reference here is the error I get when not using the var syntax.
Wrapped Java.lang. IllegalArgumentException: Don't know how to callback of type: org.appcelerator.Kroll.Proxy$1
-
Studio Hitori
This issue has been raised in ticket #3184. If its resolution is important to you, then you can register with Lighthouse and watch it to receive updates by email about its status and ultimate fix.
Please close this thread, so others can find this information easily.
Many thanks for bring it to the community's attention. :)