{ "id": "63556", "key": "TIMOB-2924", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11241", "name": "Release 1.6.0 M08", "archived": true, "released": true, "releaseDate": "2011-02-07" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-08-17T18:10:51.000+0000", "created": "2011-04-15T03:33:02.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "defect", "enterprise", "release-1.6.0", "reported-1.6.0", "rplist" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-08-17T18:10:51.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

Problem

\n

In the app.js, events bound to Ti.Android.currentActivity do not\nfire. Events include: create, start, pause, resume, stop, and\ndestroy.

\n

Workaround

\n

Open a window with a URL set, and the nav bar hidden, modal\ntrue, or fullscreen true. In that JavaScript context, most of the\nevents will fire. I was not able to get \"create\", \"destroy\", or\n\"start\" to fire (a separate issue, perhaps?).

\n

Sample Code

\n

The following code, placed alone in an app.js, demonstrates the\nproblem. Launch the app, press the home button, and no events will\nfire. If you change the variable \"forceHeavyweight\" to true, app.js\nwill open itself as a heavyweight window, and most of the events\nwill fire.

\n
\n(function() {\n    // force this into a heavyweight window?\n    var forceHeavyweight = false;\n    if (forceHeavyweight && Ti.UI.currentWindow == null) {\n        Ti.API.info('opening heavyweight window...');\n        Ti.UI.createWindow({ url: 'app.js', navBarHidden: true }).open();\n        return;\n    }\n\n    // add listeners\n    function addListener(event) {\n        Titanium.Android.currentActivity.addEventListener(event, function() {\n            Ti.API.info(event + ' fired!');\n        });\n    }\n\n    addListener('create');\n    addListener('start');\n    addListener('pause');\n    addListener('resume');\n    addListener('stop');\n    addListener('destroy');\n\n    // add some stuff to the window\n    var win = Titanium.UI.createWindow({\n        title: 'Window One',\n        backgroundColor: '#fff'\n    });\n    win.add(Titanium.UI.createLabel({\n        color: '#999',\n        text: 'I am a resumable app!',\n        font: { fontSize: 20, fontFamily: 'Helvetica Neue' },\n        textAlign: 'center',\n        width: 'auto'\n    }));\n    win.open();\n})();\n
\n

Trace Log from Normal App.js, not Heavyweight

\n
\n[INFO] Deployed AndroidEvents ... Application should be running.\n[TRACE] I/Log ( 335): (main) [0,0] checkpoint, app created.\n[TRACE] I/TiApplication( 335): (main) [200,200] Titanium 1.6.0 (2011/01/19 13:14 ad18bd...)\n[TRACE] D/TiApplication( 335): (main) [4,204] Application onCreate\n[TRACE] E/TiPlatformHelper( 335): (main) [224,428] renaming ID\n[TRACE] I/Log ( 335): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null\n[TRACE] E/TiRootActivity( 335): (main) [1,1] Instance Count: 0\n[TRACE] D/dalvikvm( 335): GC_FOR_MALLOC freed 3437 objects / 335208 bytes in 88ms\n[TRACE] D/TiApplication( 335): (main) [198,199] Analytics Event: type=ti.start\n[TRACE] D/TiApplication( 335): event=ti.start\n[TRACE] D/TiApplication( 335): timestamp=2011-01-24T22:55:35.121-0600\n[TRACE] D/TiApplication( 335): mid=f6d0df25-fb8e-44d4-9d62-50a738bc66ef\n[TRACE] D/TiApplication( 335): sid=fc76c8d3-0330-4a71-8e7f-960de640596e\n[TRACE] D/TiApplication( 335): aguid=3240e29c-aedb-4d35-88c3-48632e990e49\n[TRACE] D/TiApplication( 335): isJSON=true\n[TRACE] D/TiApplication( 335): payload={\"os\":\"sdk\",\"tz\":-360,\"nettype\":\"MOBILE\",\"deploytype\":\"development\",\"app_version\":\"1.0\",\"osver\":\"2.2\",\"un\":\"android-build\",\"version\":\"1.6.0\"}\n[TRACE] E/TiApplication( 335): (main) [263,462] APP PROXY: [Ti.App]\n[TRACE] E/ROOT ( 335): (main) [366,828] Leaving TiRootActivity.onCreate\n[TRACE] I/Log ( 335): (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@44f4cec8\n[TRACE] I/TiRootActivity( 335): (Thread-9) [8,8] eval app.js\n[TRACE] D/KrollContext( 335): (kroll$1) [26,34] Running evaluated script: app://app.js\n[TRACE] W/TiAnalyticsSvc( 335): (Thread-10) [82,116] Analytics Service Started\n[TRACE] D/dalvikvm( 335): GC_FOR_MALLOC freed 5312 objects / 356272 bytes in 138ms\n[TRACE] I/ActivityManager( 60): Displayed activity com.dawson.androidevents/.AndroideventsActivity: 4214 ms (total 4214 ms)\n[TRACE] I/TiAnalyticsSvc( 335): (Thread-10) [1896,2012] Sending 1 analytics events.\n[TRACE] D/dalvikvm( 335): GC_FOR_MALLOC freed 6016 objects / 367320 bytes in 81ms\n[TRACE] D/dalvikvm( 335): GC_FOR_MALLOC freed 419 objects / 22432 bytes in 81ms\n[TRACE] W/TiAnalyticsSvc( 335): (Thread-10) [1652,3664] Stopping Analytics Service\n[TRACE] D/dalvikvm( 269): GC_EXPLICIT freed 948 objects / 54512 bytes in 72ms\n[TRACE] D/dalvikvm( 277): GC_EXPLICIT freed 694 objects / 52368 bytes in 105ms\n[TRACE] I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher }\n[TRACE] D/TiRootActivity( 335): (main) [143099,146763] root activity onPause, context = org.appcelerator.titanium.TiContext@44f4cec8\n[TRACE] W/InputManagerService( 60): Ignoring hideSoftInput of: com.android.internal.view.IInputMethodClient$Stub$Proxy@45017aa8\n[TRACE] I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher }\n[TRACE] W/InputManagerService( 60): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44edca88\n[TRACE] I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.dawson.androidevents/.AndroideventsActivity bnds=[125,70][235,188] }\n[TRACE] I/Log ( 335): (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@44f4cec8\n[TRACE] D/dalvikvm( 141): GC_EXPLICIT freed 1171 objects / 85352 bytes in 105ms\n[TRACE] D/dalvikvm( 269): GC_EXPLICIT freed 374 objects / 19360 bytes in 68ms\n
\n

Trace Log from Heavyweight Window

\n
\n[TRACE] I/TiRootActivity( 710): (Thread-9) [12,12] eval app.js\n[TRACE] D/KrollContext( 710): (kroll$1) [12,24] Running evaluated script: app://app.js\n[TRACE] W/TiAnalyticsSvc( 710): (Thread-10) [125,149] Analytics Service Started\n[INFO] [234,383] opening heavyweight window...\n[TRACE] D/dalvikvm( 710): GC_FOR_MALLOC freed 5313 objects / 357472 bytes in 88ms\n[TRACE] I/ActivityManager( 60): Displayed activity com.dawson.androidevents/.AndroideventsActivity: 5145 ms (total 5145 ms)\n[TRACE] I/ActivityManager( 60): Starting activity: Intent { cmp=com.dawson.androidevents/org.appcelerator.titanium.TiActivity (has extras) }\n[TRACE] D/TiRootActivity( 710): (main) [1502,1885] root activity onPause, context = org.appcelerator.titanium.TiContext@44facea0\n[TRACE] D/qemud ( 38): fdhandler_accept_event: accepting on fd 10\n[TRACE] D/qemud ( 38): created client 0x17018 listening on fd 15\n[TRACE] D/qemud ( 38): client_fd_receive: attempting registration for service 'sensors'\n[TRACE] D/qemud ( 38): client_fd_receive: -> received channel id 10\n[TRACE] D/qemud ( 38): client_registration: registration succeeded for client 10\n[TRACE] D/qemud ( 38): fdhandler_event: disconnect on fd 15\n[TRACE] I/ActivityManager( 60): Displayed activity com.dawson.androidevents/org.appcelerator.titanium.TiActivity: 572 ms (total 572 ms)\n[TRACE] D/KrollContext( 710): (kroll$2) [745,2630] Running evaluated script: app://app.js\n[TRACE] I/TiAnalyticsSvc( 710): (Thread-10) [352,2982] Sending 1 analytics events.\n[TRACE] D/dalvikvm( 710): GC_FOR_MALLOC freed 5577 objects / 367144 bytes in 74ms\n[TRACE] D/dalvikvm( 710): GC_FOR_MALLOC freed 2802 objects / 149512 bytes in 69ms\n[TRACE] W/TiAnalyticsSvc( 710): (Thread-10) [1672,4654] Stopping Analytics Service\n[TRACE] I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher }\n[INFO] [2643,7297] pause fired!\n[TRACE] W/InputManagerService( 60): Ignoring hideSoftInput of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4504c618\n[INFO] [534,7831] stop fired!\n[TRACE] I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.dawson.androidevents/.AndroideventsActivity bnds=[125,70][235,188] }\n[INFO] [2510,10341] start fired!\n[INFO] [2,10343] resume fired!\n[TRACE] D/dalvikvm( 262): GC_EXPLICIT freed 105 objects / 5024 bytes in 59ms\n[TRACE] D/dalvikvm( 126): GC_EXPLICIT freed 1164 objects / 64584 bytes in 82ms\n[TRACE] D/dalvikvm( 585): GC_EXPLICIT freed 63 objects / 3600 bytes in 60ms\n[TRACE] W/KeyCharacterMap( 710): No keyboard for id 0\n[TRACE] W/KeyCharacterMap( 710): Using default keymap: /system/usr/keychars/qwerty.kcm.bin\n[INFO] [37330,47673] pause fired!\n[TRACE] I/Log ( 710): (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@44facea0\n[INFO] [700,700] stop fired!\n[TRACE] E/TiBaseActivity( 710): (main) [49,749] Layout cleanup.\n[TRACE] D/TiRootActivity( 710): (main) [1872,2621] root activity onPause, context = org.appcelerator.titanium.TiContext@44facea0\n[TRACE] D/TiRootActivity( 710): (main) [489,3110] root activity onDestroy, context = org.appcelerator.titanium.TiContext@44facea0\n
\n

Associated Helpdesk Ticket

\n

http://developer.appcelerator.com/helpdesk/view/68461

{html}", "attachment": [], "flagged": false, "summary": "Android: Activity related events don't fire in app.js", "creator": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "environment": null, "comment": { "comments": [ { "id": "129721", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

We found this on Friday but only verified it was a problem as\nwell on Monday.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:33:02.000+0000", "updated": "2011-04-15T03:33:02.000+0000" }, { "id": "129722", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [4cdb1abb380f780b42ada014e05415402a8c335b])\n[#2924] commiting my changes for the events being\nfired. Create is still missing. Marshall will resolve it along with\n2990. \nhttps://github.com/appcelerator/titanium_mobile/commit/4cdb1abb380f...

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:33:03.000+0000", "updated": "2011-04-15T03:33:03.000+0000" }, { "id": "129723", "author": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [76647275afd7304f48ea8535b55a3db9e1e1f666])\nmoved all async / blocking callbacks to a new message queue\nimplementation that allows single loop iteration and provides\nbetter \"dispatch while blocking\" behavior, fixing the vast majority\nof our deadlock issues. Kitchensink is now running mostly well on\ntop of these changes. Changed setTimeout/setInterval to use handler\nmessages instead of timer threads for better consistency. Added an\nintermediary TiActivityWindows class between launched internal\nactivities and TiUIWindow for better inline notification and\nreaction to Activity onCreate(). fixed the weird activity indicator\nas widget code in kitchensink for Android. [#2990]\n[#2924] \nhttps://github.com/appcelerator/titanium_mobile/commit/76647275afd7...

{html}", "updateAuthor": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:33:03.000+0000", "updated": "2011-04-15T03:33:03.000+0000" }, { "id": "129724", "author": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

This was fixed with the lifecycle merge, also see the testcase\nattached to #2990

{html}", "updateAuthor": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:33:03.000+0000", "updated": "2011-04-15T03:33:03.000+0000" }, { "id": "129725", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

[INFO] Titanium SDK version: 1.6.0 (02/08/11\n20:55 bd9d124...) galaxy tab (2.2.2) G1 (1.6) Nexus S (2.3) sim 2.1\nusing content from 2990

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:33:04.000+0000", "updated": "2011-04-15T03:33:04.000+0000" }, { "id": "129726", "author": { "name": "andreassandberg", "key": "andreassandberg", "displayName": "Andreas sandberg", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Marshall, the activity events don't seem to fire correctly when\na tab group instead of a window is created in app.js. They will\nfire when the app is launched but the resume event will not fire if\nhitting the home button and then re-visiting the application:

\n


\nvar tabGroup = Titanium.UI.createTabGroup();

\n

// main window var tmpWindow =\nTitanium.UI.createWindow({

\n{mkd-extraction-07b3db81cd896879545475daf0729a81}\n

}); var tmpTab = Titanium.UI.createTab({

\n{mkd-extraction-21f199430d96bbfb8d3a23a1dfb069c9}\n

});

\n

tabGroup.addTab(tmpTab);
\ntabGroup.open();

\n

Ti.Android.currentActivity.addEventListener('resume', function()\n{

\n{mkd-extraction-5e267346fda20e806190c88b15ea5349}\n

});

\n

Ti.Android.currentActivity.addEventListener('start', function()\n{

\n{mkd-extraction-04c48c1bcecf758460756ec5b3d21fcf}\n

});

\n

Ti.Android.currentActivity.addEventListener('pause', function()\n{

\n{mkd-extraction-ba7a59329baca5563699fa486f1834b4}\n

});

{html}", "updateAuthor": { "name": "andreassandberg", "key": "andreassandberg", "displayName": "Andreas sandberg", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:33:04.000+0000", "updated": "2011-04-15T03:33:04.000+0000" }, { "id": "163279", "author": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The events fire only once on tabgroup activity, but works fine with a heavyweight window.\r\nSample code:\r\n{code}\r\nTitanium.UI.setBackgroundColor('#000');\r\n\r\n// create tab group\r\nvar tabGroup = Titanium.UI.createTabGroup();\r\n\r\n\r\n//\r\n// create base UI tab and root window\r\n//\r\nvar win1 = Titanium.UI.createWindow({ \r\n title:'Tab 1',\r\n backgroundColor:'#fff'\r\n});\r\nvar tab1 = Titanium.UI.createTab({ \r\n icon:'KS_nav_views.png',\r\n title:'Tab 1',\r\n window:win1\r\n});\r\n\r\nvar label1 = Titanium.UI.createLabel({\r\n\tcolor:'#999',\r\n\ttext:'I am Window 1',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\ttextAlign:'center',\r\n\twidth:'auto'\r\n});\r\n\r\nwin1.add(label1);\r\n\r\n//\r\n// create controls tab and root window\r\n//\r\nvar win2 = Titanium.UI.createWindow({ \r\n title:'Tab 2',\r\n backgroundColor:'#fff'\r\n});\r\nvar tab2 = Titanium.UI.createTab({ \r\n icon:'KS_nav_ui.png',\r\n title:'Tab 2',\r\n window:win2\r\n});\r\n\r\nvar label2 = Titanium.UI.createLabel({\r\n\tcolor:'#999',\r\n\ttext:'I am Window 2',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\ttextAlign:'center',\r\n\twidth:'auto'\r\n});\r\n\r\nwin2.add(label2);\r\n\r\n\r\n\r\n//\r\n// add tabs\r\n//\r\ntabGroup.addTab(tab1); \r\ntabGroup.addTab(tab2); \r\n\r\n\r\n// open tab group\r\ntabGroup.open();\r\n\r\nTi.Android.currentActivity.addEventListener('pause', function(e){\r\n\tTi.API.info('changeState App is pausing');\r\n});\r\n\r\nTi.Android.currentActivity.addEventListener('resume', function(e){\r\n\tTi.API.info('changeState App is resuming');\r\n});\r\n{code}\r\n\r\nh3. Associated Hepdesk ticket:\r\nappc.me/c/APP-834283", "updateAuthor": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-17T17:50:40.000+0000", "updated": "2011-08-17T17:53:59.000+0000" }, { "id": "163281", "author": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-17T18:10:51.000+0000", "updated": "2011-08-17T18:10:51.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }