{ "id": "129859", "key": "AC-989", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2014-05-19T05:13:41.000+0000", "created": "2014-05-01T09:28:16.000+0000", "labels": [ "actionbar", "android", "menu", "triage" ], "versions": [], "issuelinks": [ { "id": "37693", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "129733", "key": "TIMOB-16889", "fields": { "summary": "Android: Adding 'resume' event to Ti.Android.currentActivity does not work with SDK >= 3.2.0", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:37:19.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "The good news is that with AppCompat TabGroups and Windows share the same base class - ActionBarActivity, and starting with 3.3.0 onCreateOptionsMenu is called when the activity is started across all Android versions. See http://developer.android.com/guide/topics/ui/menus.html\r\nThe developer guide also states: \"However, you should use onCreateOptionsMenu() only to create the initial menu state and not to make changes during the activity lifecycle.\" This is where the problems begin:\r\n\r\n*For TabGroups, the activity property is only valid after the TabGroup open event*. If the dev wants to set menu options - that should be the time to set activity.onCreateOptionsMenu - *and not call* activity.invalidateOptionsMenu after onCreateOptionsMenu was set! The example in the docs is wrong on this point. The reason to not call invalidateOptionsMenu() is that there is no options menu to invalidate at this point! Apparently, on Gingerbread this has no effect, but on Jelly Bean I have seen very strange behavior on occasion due to this issue. If you set debug logging on the SDK, you will see that onCreateOptionsMenu is actually called twice in this case, and apparently the first time is too early for the system, thus nasty behavior on occasion.\r\n\r\n*In the case of Window objects*, however, the system calls onCreateOptionsMenu *prior* to the open event. So for 3.3.0 at this time the correct behavior is to set onCreateOptionsMenu *prior to the window opening*, and again - not call invalidateOptionsMenu.\r\n\r\nIn general, if invalidateOptionsMenu is called, it should be done *after* the initial call to onCreateOptionsMenu - and we don't have a suitable event in the SDK for this, at this time.\r\n\r\nProposal:\r\n1. Clearly state in the documentation that TabGroup.activity.onCreateOptionsMenu should be set during the TabGroup open event handler, and that Window.activity.onCreateOptionsMenu should be set as soon as the Window is created. And of course *not call* invalidateOptionsMenu after either.\r\n2. Never call invalidateOptionsMenu before there was a valid options menu prior.\r\n3. The safest solution is set onCreateOptionsMenu in the TabGroup and Window initialization dictionary.\r\n4. onPrepareOptionsMenu is probably used more often that it should be. Looking in the Android docs, http://developer.android.com/reference/android/app/Activity.html#onCreateOptionsMenu%28android.view.Menu%29 state \"You can safely hold on to menu (and any items created from it), making modifications to it as desired, until the next time onCreateOptionsMenu() is called. \"", "attachment": [], "flagged": false, "summary": "Android: lack of clarity or consistency with onCreateOptionsMenu, onPrepareOptionsMenu", "creator": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "subtasks": [], "reporter": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "environment": "Android SDK 3.3.0", "comment": { "comments": [ { "id": "303202", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "Just to make this issue even more clear: the root cause is that onCreateOptionsMenu is not in the TabGroup and Window creation dictionary.", "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-05-01T18:24:09.000+0000", "updated": "2014-05-01T18:24:09.000+0000" }, { "id": "305441", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-05-18T12:30:34.000+0000", "updated": "2014-05-18T12:30:34.000+0000" }, { "id": "305445", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Resolving this as a duplicate of TIMOB-16889 as suggested by the reporter. Reporter has also added relevant comments to TIMOB-16889 ticket.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-05-19T05:13:41.000+0000", "updated": "2014-05-19T05:13:41.000+0000" }, { "id": "305491", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-05-19T12:39:21.000+0000", "updated": "2014-05-19T12:39:21.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }