{ "id": "150043", "key": "TIMOB-19328", "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": [], "resolution": null, "resolutiondate": null, "created": "2015-07-31T02:25:14.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2015-11-13T02:46:09.000+0000", "status": { "description": "This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.", "name": "Reopened", "id": "4", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "It was working fine. Recently I found this bug, but not sure starting which SDK version the problem existed.\r\n\r\nCreate a default Alloy project with the following:\r\n\r\nindex.xml\r\n{code}\r\n\r\n\t\r\n\r\n{code}\r\n\r\nindex.js\r\n{code}\r\nfunction doClose() {\r\n\tTi.Android.unregisterBroadcastReceiver(bc);\r\n}\r\n\r\n$.index.open();\r\n\r\nvar onReceived = function(e) {\r\n\tTi.API.info(\"received!\");\r\n};\r\nvar bc = Ti.Android.createBroadcastReceiver({\r\n\tonReceived : onReceived\r\n});\r\nTi.Android.registerBroadcastReceiver(bc, [\"android.intent.action.PHONE_STATE\"]);\r\n{code}\r\n\r\ntiapp.xml (use the following for the android section)\r\n{code}\r\n \r\n \t\r\n \r\n \t\r\n \r\n{code}\r\n\r\nAfter launching the app, call to the cellphone and see the onReceived function executed twice for one broadcast.", "attachment": [], "flagged": false, "summary": "Android: broadcast receiver always executed twice for one broadcast", "creator": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "SDK 4.1.0/Android 5.0", "closedSprints": [ { "id": 464, "state": "closed", "name": "2015 Sprint 17 SDK", "startDate": "2015-08-15T00:30:59.243Z", "endDate": "2015-08-29T00:30:00.000Z", "completeDate": "2015-08-31T08:10:47.969Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "361148", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This isn't a bug. The phone_state broadcast supposed to fire every time the phone's state changes: http://developer.android.com/reference/android/telephony/TelephonyManager.html#ACTION_PHONE_STATE_CHANGED\r\n\r\nSo if you are receiving a phone call, there are multiple phone states (i.e, CALL_STATE_IDLE, CALL_STATE_OFFHOOK, and CALL_STATE_RINGING). I've also tested with android.intent.action.AIRPLANE_MODE, and it works as expected (only fired once)", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-25T22:01:39.000+0000", "updated": "2015-08-25T22:05:14.000+0000" }, { "id": "361150", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "For each phone state the receiver is called twice!! The bug seems to only happen with phone state. Please test using the test case under the specified environment.\r\n\r\nPlease re-open this case or I'll need to create another case.", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-25T22:16:35.000+0000", "updated": "2015-08-25T22:16:35.000+0000" }, { "id": "369846", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Please use the sample code to regenerate the issue. \r\n\r\nindex.xml\r\n{code}\r\n\r\n\r\n\t\r\n\r\n\r\n{code}\r\nindex.js\r\n{code}\r\nfunction doClose() {\r\n\r\n\tTi.Android.unregisterBroadcastReceiver(bc);\r\n\r\n}\r\n\r\n \r\n\r\n$.index.open();\r\n\r\n \r\n\r\nvar onReceived = function(e) {\r\n\r\n\tTi.API.info(\"received!\");\r\n\r\n};\r\n\r\nvar bc = Ti.Android.createBroadcastReceiver({\r\n\r\n\tonReceived : onReceived\r\n\r\n});\r\n\r\nTi.Android.registerBroadcastReceiver(bc, [\"android.intent.action.PHONE_STATE\"]);\r\n{code}\r\ntiapp.xml (use the following for the android section)\r\n{code}\r\n \r\n\r\n \t\r\n\r\n \r\n\r\n \t\r\n\r\n \r\n{code}\r\n\r\nLet's have one more look at this.\r\n", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-11-12T02:39:10.000+0000", "updated": "2015-11-12T02:39:10.000+0000" }, { "id": "370019", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Sorry just realised the sample code commented above is exactly the same as ticket description. ", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-11-12T04:13:09.000+0000", "updated": "2015-11-12T04:13:24.000+0000" }, { "id": "370031", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Tested this with an Emulator with Android 5.1.0 using the above code.\r\nSimulated an inbound call by running the following commands based on http://developer.android.com/tools/devices/emulator.html#telephony\r\n\r\n1) `telnet localhost 5554`\r\n2) `gsm call 1111`\r\n\r\nBroadcast receiver executed once when Picking up phone call.\r\nBroadcast receiver executed once more when phone call ended and went back to app.\r\n\r\nUnable to reproduce broadcast receiver executing twice.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-11-12T06:46:26.000+0000", "updated": "2015-11-12T06:46:26.000+0000" }, { "id": "370101", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Have you tested on a device? I tested it on my HTC One M7. Call pickup executes twice the receiver. Call end executes twice the receiver as well.", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-12T17:45:14.000+0000", "updated": "2015-11-12T17:45:14.000+0000" }, { "id": "370162", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~shawnlan] May I know which Android version HTC One M7 is running?", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-11-13T02:25:56.000+0000", "updated": "2015-11-13T02:25:56.000+0000" }, { "id": "370164", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "5.0.2", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-13T02:40:24.000+0000", "updated": "2015-11-13T02:40:24.000+0000" }, { "id": "370165", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Thanks. I'll try to test on something similar to that.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-11-13T02:46:09.000+0000", "updated": "2015-11-13T02:46:09.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }