{ "id": "141059", "key": "TIMOB-18146", "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": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2015-07-08T07:44:42.000+0000", "created": "2014-12-06T00:51:39.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [ { "id": "16676", "description": "Release 3.4.1", "name": "Release 3.4.1", "archived": false, "released": true, "releaseDate": "2014-11-14" }, { "id": "16593", "description": "Release 4.0.0", "name": "Release 4.0.0", "archived": false, "released": true, "releaseDate": "2015-05-21" } ], "issuelinks": [ { "id": "43754", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "inwardIssue": { "id": "141060", "key": "TIMOB-18147", "fields": { "summary": "Android: Cannot get current activity from JavaScript broadcast receiver", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "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": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2017-03-17T18:02:55.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": "CAVEAT:\r\nCannot tell if this should work or not. Cannot find any official information in the Android docs. Stackoverflow and other topics say you can only send data through extras, which does work in this example.\r\n\r\nREPRODUCTION:\r\nRun the code below in the Genymotion emulator and click the \"Send Broadcast\" button.\r\n\r\nRESULTS:\r\nBroadcast is not sent.\r\n\r\nOTHER INFO:\r\nComment out line #9 (data property) and rerun the test. Intent is sent and received.\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow();\r\nvar button = Ti.UI.createButton({\r\n\ttitle : 'Send Broadcast'\r\n});\r\nbutton.addEventListener('click', function() {\r\n\r\n\tvar intent = Ti.Android.createBroadcastIntent({\r\n\t\taction: 'com.appcelerator.action.ALERT',\r\n\t\tdata: 'http://www.appcelerator.com'\r\n\t});\r\n\tTi.Android.currentActivity.sendBroadcast(intent);\r\n});\r\nwin.add(button);\r\nwin.open();\r\n\r\nvar broadcastReceiver = Ti.Android.createBroadcastReceiver({\r\n\tonReceived: function(e) {\r\n\t\tTi.API.info(JSON.stringify(e.intent));\r\n\t}\r\n});\r\nTi.Android.registerBroadcastReceiver(broadcastReceiver, ['com.appcelerator.action.ALERT']);\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: Cannot send Broadcast with data property defined in the intent", "creator": { "name": "bhatfield", "key": "bhatfield", "displayName": "Benjamin Hatfield", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "bhatfield", "key": "bhatfield", "displayName": "Benjamin Hatfield", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "Mac OS X 10.8.5\r\nAppcelerator Studio, build: 3.4.1.201410281743\r\nTiSDK 3.4.1.GA, 3.6.0.v20141125154117\r\nTi CLI 3.5.0-dev\r\nAndroid API level 21\r\nGenymotion Google Nexus 7 - 4.4.4 - API 19 - 800x1280", "closedSprints": [ { "id": 441, "state": "closed", "name": "2015 Sprint 14 SDK", "startDate": "2015-07-04T01:00:23.204Z", "endDate": "2015-07-18T01:00:00.000Z", "completeDate": "2015-07-28T06:37:47.083Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "356871", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "The 'data' in this case (most likely) is being used incorrectly. The 'data' of an intent is the data to operate on. Check here for clarification: http://developer.android.com/reference/android/content/Intent.html\r\n\r\nRelated readings just for anyone's reference (mainly for me):-\r\nhttp://docs.appcelerator.com/platform/latest/#!/guide/Android_Intents-section-43287298_AndroidIntents-AddExtraData\r\n\r\nhttp://docs.appcelerator.com/platform/latest/#!/guide/Android_Broadcast_Intents_and_Receivers", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-07-03T06:56:24.000+0000", "updated": "2015-07-03T07:12:09.000+0000" }, { "id": "356873", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "I would assume you want to send some form of information or text over. Here's an example how:\r\n{code}\r\nvar win = Ti.UI.createWindow();\r\nvar button = Ti.UI.createButton({\r\n\ttitle : 'Send Broadcast'\r\n});\r\nbutton.addEventListener('click', function() {\r\n \r\n\tvar intent = Ti.Android.createBroadcastIntent({\r\n\t\taction: 'com.appcelerator.action.ALERT'\r\n\t});\r\n\tintent.putExtra('site', 'http://www.appcelerator.com');\r\n\tintent.putExtra('timestamp', new Date());\r\n\tintent.putExtra(Ti.Android.EXTRA_TEXT, 'Some text that we want to share');\r\n\tTi.Android.currentActivity.sendBroadcast(intent);\r\n});\r\nwin.add(button);\r\nwin.open();\r\n \r\nvar broadcastReceiver = Ti.Android.createBroadcastReceiver({\r\n\tonReceived: function(e) {\r\n\t\tTi.API.info(JSON.stringify(e.intent)+\" - \"+e.intent.getStringExtra('timestamp') +\" - \"+e.intent.getStringExtra('site')\r\n\t +\" - \"+e.intent.getStringExtra(Ti.Android.EXTRA_TEXT));\r\n\t\tvar toast = Ti.UI.createNotification({\r\n\t message:JSON.stringify(e.intent)+\" - \"+e.intent.getStringExtra('timestamp') +\" - \"+e.intent.getStringExtra('site')\r\n\t +\" - \"+e.intent.getStringExtra(Ti.Android.EXTRA_TEXT),\r\n\t duration: Ti.UI.NOTIFICATION_DURATION_LONG\r\n\t\t});\r\n\t\ttoast.show();\r\n\t}\r\n});\r\nTi.Android.registerBroadcastReceiver(broadcastReceiver, ['com.appcelerator.action.ALERT']);\r\n{code}\r\n", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-07-03T07:09:32.000+0000", "updated": "2015-07-03T07:09:32.000+0000" }, { "id": "356874", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~bhatfield] If the answer is acceptable, can this ticket be closed?", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-07-03T07:10:05.000+0000", "updated": "2015-07-03T07:10:05.000+0000" }, { "id": "413517", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-17T18:02:55.000+0000", "updated": "2017-03-17T18:02:55.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }