{ "id": "126492", "key": "TIMOB-16492", "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": "15935", "description": "2014 Sprint 06", "name": "2014 Sprint 06", "archived": true, "released": true, "releaseDate": "2014-03-28" }, { "id": "15936", "description": "2014 Sprint 06 SDK", "name": "2014 Sprint 06 SDK", "archived": true, "released": true, "releaseDate": "2014-03-28" }, { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-03-19T19:51:38.000+0000", "created": "2014-02-18T15:03:34.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "module_android", "qe-closed-3.3.0", "qe-manualtest", "supportTeam" ], "versions": [ { "id": "15856", "description": "Release 3.2.1", "name": "Release 3.2.1", "archived": false, "released": true, "releaseDate": "2014-02-10" } ], "issuelinks": [], "assignee": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "updated": "2014-08-05T23:24:30.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": "h6.Issue description\r\nI am using a simple background service to create a notification. The notification intent has extra data to it, and is then fired. The notification is displayed in the status bar. I pull down the bar and my app is opened/resumed. I try to read the intent data, but it appears as if the app is not resuming and even if I try to get both resume(d) and or the open on the activity I am not able to read any intent data added from the background service.\r\n\r\nPlease note that even if the service is registered again at next start the notification should still be possible to catch. I have read all things I can get, but I have not found any instruction on how to capture the notification intent data. All guides stop where it has appeared in the status bar, even den android dev ones. \r\n\r\nh6.Test outcomes\r\n- Data intent is only retrieved when you get it through android service resource: \"app/lib/background_locationservice_android.js\"\r\n\r\n{code}\r\n//DISPLAYS ALERT BOX (\"TEST2\")\r\nvar service = Ti.Android.currentService;\r\nif (service) {\r\n\tvar intent = service.getIntent();\r\n\tvar teststring = intent.getStringExtra(\"message\");\r\n\talert(teststring);\r\n\r\n\tservice.addEventListener(\"taskremoved\", function() {\r\n\t\tTi.Android.NotificationManager.cancelAll();\r\n\t\tTi.Android.stopService(intent);\r\n\t});\r\n}\r\n{code}\r\n\r\nHowever you can't get intent data either in app/alloy.js or controllers/index.js\r\n\r\nh6.Steps to reproduce\r\n# Get and run stripped down version on Android device.\r\n# Wait until a notification get trigger.\r\n# Quit app then click at notification at the statusBar. \r\n# Monitor Logs. Depending where was getStringExtra set will be the outcome.\r\n\r\nSample: https://www.dropbox.com/s/wow58vtprsiktu3/Arkiv_TestCase.zip", "attachment": [ { "id": "45992", "filename": "Arkiv.zip", "author": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "created": "2014-02-18T15:03:34.000+0000", "size": 5903193, "mimeType": "application/zip" } ], "flagged": false, "summary": "Android: Not able to capture intent data from a Notification created from Background service", "creator": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Android KitKat 4.4\r\nTitanium SDK 3.2.1 Titanium", "comment": { "comments": [ { "id": "294332", "author": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Exposed a new method to expose root activity. Only the intent as part of the launched activity will have the extra data. \r\nRight now after a window is opened, there is no method to access the root activity.\r\n\r\nExisting code should work if 'Ti.Android.currentActivity' is called before window is opened. Something like\r\n\r\n{code}\r\nvar activity = Ti.Android.currentActivity;\r\nvar intent = activity.getIntent();\r\nTi.API.info('interval = '+intent.getIntExtra('interval',0)+' message='+intent.getStringExtra('message'));\r\n{code}\r\n\r\nor use the new API 'getRootActivity' inside 'open' to get the data\r\n\r\nSomething like \r\n\r\n{code}\r\nvar rootActivity = Ti.Android.getRootActivity();\r\nvar rootIntent = rootActivity.getIntent();\r\nTi.API.info('RootIntent message='+rootIntent.getStringExtra('message'));\r\n{code}\r\n\r\nPR\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/pull/5368\r\n", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-02-24T14:17:18.000+0000", "updated": "2014-02-24T16:25:36.000+0000" }, { "id": "297869", "author": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "body": "New pull request based on latest master.\n\nhttps://github.com/appcelerator/titanium_mobile/pull/5493\n\nUsage\nvar rootIntent = Ti.App.Android.launchIntent;\nTi.API.info('RootIntent message='+rootIntent.getStringExtra('message'));", "updateAuthor": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2014-03-19T15:05:16.000+0000", "updated": "2014-03-19T15:05:16.000+0000" }, { "id": "297944", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Test Code\n{code}\nvar launchIntent = Ti.Android.currentActivity.intent; \n\nvar checkInWindow = false;\nvar testMessage = launchIntent.getStringExtra(\"message\");\nif(testMessage != null) {\n\tcheckInWindow = true;\n}\n\nvar win = Ti.UI.createWindow({\n\tbackgroundClor:'white',\n\texitOnClose:true\n});\n\nif(checkInWindow == true) {\n\t\n\tvar l1 = Ti.UI.createLabel({top:50,text:testMessage});\n\tvar l2 = Ti.UI.createLabel({bottom:50,text:''});\n\tvar l3 = Ti.UI.createLabel({text: 'VALUES MUST BE SAME'});\n\t\n\twin.add(l1);\n\twin.add(l2);\n\twin.add(l3);\n\t\n\twin.addEventListener('open',function(e){\n\t\tl2.text = Ti.App.Android.launchIntent.getStringExtra(\"message\");\n\t});\n\t\n} else {\n\tvar btn = Ti.UI.createButton({title:'CREATE PENDING INTENT'});\n\twin.add(btn);\n\tbtn.addEventListener('click',function(e){\n\t\tTi.API.info('BUTTON CLICK');\n\n\t\tvar intent = Ti.Android.createIntent({\n\t\t flags : Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_ACTIVITY_NEW_TASK,\n\t\t // our application app id activity class. Replace as required\n\t\t className : 'com.appcelerator.titaniumtest.TitaniumtestActivity'\n\t\t});\n\t\tintent.putExtra('message', \"This is test string\");\n\t\tintent.addCategory(Ti.Android.CATEGORY_LAUNCHER);\n\t\tTi.API.info('Created intent');\n\t\t// Create a PendingIntent to tie together the Activity and Intent\n\t\tvar pending = Titanium.Android.createPendingIntent({\n\t\t intent: intent,\n\t\t flags: Titanium.Android.FLAG_UPDATE_CURRENT\n\t\t});\n\t\tTi.API.info('Created pending intent');\n\t\t// Create the notification\n\t\tvar notification = Titanium.Android.createNotification({\n\t\t // icon is passed as an Android resource ID -- see Ti.App.Android.R.\n\t\t //icon: 'images/ic_search.png',\n\t\t contentTitle: 'Test Intent',\n\t\t contentText : 'Click to return to the application.',\n\t\t contentIntent: pending\n\t\t});\n\t\tTi.API.info('Created notification');\n\t\t// Send the notification.\n\t\tTitanium.Android.NotificationManager.notify(1, notification);\n\t\tTi.API.info('notification sent');\n\t\t\n\t\tsetTimeout(function(){\n\t\t\twin.activity.finish();\n\t\t},200);\n\t\t\n\t});\n}\n\nwin.open();\n{code}", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-03-19T19:50:44.000+0000", "updated": "2014-03-19T19:50:44.000+0000" }, { "id": "302691", "author": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Intent data is successfully captured from a Notification created from Background service, tested using the test code by Vishal Duggal.\r\nIntent message is displayed on app screen when clicking the notification in the notification bar.\r\n\r\nVerified the fix on:\r\nDevice : Google Nexus 4, Android Version: 4.1.1\r\nSDK: 3.3.0.v20140425191906\r\nCLI version : 3.3.0-dev\r\nOS : MAC OSX 10.9.2\r\nAlloy: 1.4.0-dev\r\nACS: 1.0.14\r\nnpm:1.3.2\r\nAppcelerator Studio, build: 3.3.0.201404251359\r\ntitanium-code-processor: 1.1.1-alpha\r\nXCode : 5.1.1", "updateAuthor": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2014-04-28T11:53:48.000+0000", "updated": "2014-04-28T11:53:48.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }