{ "id": "84180", "key": "TIMOB-6833", "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": "12094", "description": "", "name": "Sprint 2012-02", "archived": true, "released": true, "releaseDate": "2012-01-29" }, { "id": "12593", "name": "Release 2.0.0", "archived": false, "released": true, "releaseDate": "2012-03-30" }, { "id": "12677", "description": "Release 1.8 Service Pack 1", "name": "Release 1.8.1", "archived": true, "released": true, "releaseDate": "2012-01-31" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-02-10T00:12:57.000+0000", "created": "2011-12-21T15:41:33.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "module_notification_manager", "parity", "qe-testadded" ], "versions": [ { "id": "12570", "name": "Release 1.7.5", "archived": true, "released": true, "releaseDate": "2011-11-02" }, { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" } ], "issuelinks": [], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-03-04T21:54:47.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": "h4. PROBLEM DESCRIPTION\r\nThe data I get from notifications I create remains cached on Android.\r\n\r\nh4. STEPS TO REPRODUCE\r\n0. Create new mobile project with Android support.\r\n1. Paste the above code into app.js\r\n2. Compile.\r\n3. Put a value in the field on the window\r\n4. Click the button, we create a pending notification with the data you typed\r\n5. Find the notification in the Android notification bar and click it\r\n6. The app instance alread open is found and the \"newintent\" event correctly fires\r\n7. The data we get back from the event is correct if this is the first try\r\n8. Do steps 1 - 4 again with a different value in the textfield\r\n\r\nh4. ACTUAL RESULTS\r\nYou will get a cached value\r\n\r\nh4. EXPECTED RESULTS\r\nThe latest value.\r\n\r\nh4. CODE\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({navBarHidden:true});\r\n\r\n//create some simple UI\r\nvar textfield = Ti.UI.createTextField({width:300, height:'auto', top:40, left:20, hintText:'enter message'});\r\nvar button = Ti.UI.createButton({title:'Send Notification', width:'auto', top:120, left:20, height:'auto'});\r\nvar label = Ti.UI.createLabel({width:'auto', top:200, left:20, height:'auto', width:200, text:'Message from intent:'});\r\nvar msgLabel = Ti.UI.createLabel({width:'auto', top:240, left:20, height:'auto', width:200, backgroundColor:'lightgrey', text:'---'});\r\n\r\nwin.add(textfield);\r\nwin.add(button);\r\nwin.add(label);\r\nwin.add(msgLabel);\r\n\r\nwin.addEventListener(\"open\", function(evt) {\r\n\tbutton.addEventListener(\"click\", function(evt) {\r\n\t\t\r\n\t\tTi.UI.Android.hideSoftKeyboard();\r\n\t\tmsgLabel.text = \"---\"; //reset any previous text value\r\n\r\n\t\t//grab the user input\r\n\t\tvar message = textfield.value;\r\n\t\tif (!message) {\r\n\t\t\talert('you must provide a message');\r\n\t\t\treturn;\r\n\t\t} else {\r\n\t\t\t//clear out what was typed\r\n\t\t\ttextfield.value = '';\r\n\t\t}\r\n\t\t\r\n\t\t//put some custom data into an intent\r\n\t var intent = Ti.Android.createIntent(\r\n\t {\r\n\t action: Ti.Android.ACTION_MAIN,\r\n\t flags: Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP,\r\n\t className: \"org.appcelerator.titanium.TiActivity\",\r\n\t packageName: Ti.App.id\r\n\t });\r\n\t intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);\r\n\t intent.putExtra(\"pushReceived\", message); //***** PUT\r\n\t\r\n\t\t//a pending intent to send open an activity when launched \r\n\t var pending = Ti.Android.createPendingIntent(\r\n\t {\r\n\t activity: Ti.Android.currentActivity,\r\n\t intent: intent,\r\n\t type: Ti.Android.PENDING_INTENT_FOR_ACTIVITY\r\n\t });\r\n\t\r\n\t\t//put a notification in the notification bar \r\n\t var notification = Ti.Android.createNotification(\r\n\t {\r\n\t contentIntent: pending,\r\n\t contentTitle: \"New Notification\",\r\n\t contentText: \"Msg: \" + message,\r\n\t tickerText: \"New Notification\",\r\n\t icon: Ti.App.Android.R.drawable.statusbaricon\r\n\t });\r\n\t Ti.Android.NotificationManager.notify(1, notification);\r\n\t});\r\n\r\n\t//handle the pending intent from the notification bar\r\n Titanium.Android.currentActivity.addEventListener(\"newIntent\", function(evt)\r\n {\r\n var pushObjStr = evt.intent.getStringExtra(\"pushReceived\"); //***** GET\r\n if (pushObjStr) {\r\n Ti.API.debug(\"received data: \" + pushObjStr);\r\n msgLabel.text = pushObjStr;\r\n } else {\r\n \tTi.API.debug(\"no data received\");\r\n \tmsgLabel.text = \"no data received\";\r\n }\r\n });\r\n});\r\n\r\nwin.open();\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: Cached notification data on android", "creator": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "subtasks": [], "reporter": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "environment": null, "comment": { "comments": [ { "id": "179312", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Testing steps: Run this code instead\r\n{code}\r\nvar win = Ti.UI.createWindow({fullscreen:false});\r\n\r\n//create some simple UI\r\nvar textfield = Ti.UI.createTextField({width:300, height:'auto', top:40, left:20, hintText:'enter message'});\r\nvar button = Ti.UI.createButton({title:'Send Notification', width:'auto', top:120, left:20, height:'auto'});\r\nvar label = Ti.UI.createLabel({width:'auto', top:200, left:20, height:'auto', width:200, text:'Message from intent:'});\r\nvar msgLabel = Ti.UI.createLabel({width:'auto', top:240, left:20, height:'auto', width:200, backgroundColor:'lightgrey', text:'---'});\r\n\r\nwin.add(textfield);\r\nwin.add(button);\r\nwin.add(label);\r\nwin.add(msgLabel);\r\n\r\nwin.addEventListener(\"open\", function(evt) {\r\n\t button.addEventListener(\"click\", function(evt) {\r\n\t\t//handle the pending intent from the notification bar\r\n win.activity.addEventListener(\"newIntent\", function(evt)\r\n {\r\n var pushObjStr = evt.intent.getStringExtra(\"pushReceived\"); // ***** GET\r\n if (pushObjStr) {\r\n Ti.API.debug(\"received data: \" + pushObjStr);\r\n msgLabel.text = pushObjStr;\r\n } else {\r\n Ti.API.debug(\"no data received\");\r\n msgLabel.text = \"no data received\";\r\n }\r\n });\r\n \r\n\t\tTi.UI.Android.hideSoftKeyboard();\r\n\t\tmsgLabel.text = \"---\"; //reset any previous text value\r\n\r\n\t\t//grab the user input\r\n\t\tvar message = textfield.value;\r\n\t\tif (!message) {\r\n\t\t\talert('you must provide a message');\r\n\t\t\treturn;\r\n\t\t} else {\r\n\t\t\t//clear out what was typed\r\n\t\t\ttextfield.value = '';\r\n\t\t}\r\n\t\t\r\n\t\t//put some custom data into an intent\r\n\t var intent = Ti.Android.createIntent(\r\n\t {\r\n\t action: Ti.Android.ACTION_MAIN,\r\n\t flags: Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP,\r\n\t className: \"org.appcelerator.titanium.TiActivity\",\r\n\t packageName: Ti.App.id\r\n\t });\r\n\t intent.addCategory(Ti.Android.CATEGORY_LAUNCH);\r\n\t intent.putExtra(\"pushReceived\", message); //***** PUT\r\n\t\r\n\t\t//a pending intent to send open an activity when launched \r\n\t var pending = Ti.Android.createPendingIntent(\r\n\t {\r\n\t activity: win.activity,\r\n\t intent: intent,\r\n updateCurrentIntent: false,\r\n\t type: Ti.Android.PENDING_INTENT_FOR_ACTIVITY\r\n\t });\r\n\t\r\n\t\t//put a notification in the notification bar \r\n\t var notification = Ti.Android.createNotification(\r\n\t {\r\n\t contentIntent: pending,\r\n\t contentTitle: \"New Notification\",\r\n\t contentText: \"Msg: \" + message,\r\n\t tickerText: \"New Notification\"\r\n });\r\n\t Ti.Android.NotificationManager.notify(1, notification);\r\n });\r\n\r\n});\r\n\r\nwin.open();\r\n{code}\r\nNOTE: This code provides a workaround for Ti.Android.currentActivity (which doesn't work as it should atm- it returns the context activity, which is not necessarily the current activity). The workaround uses win.activity instead ", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-13T17:50:11.000+0000", "updated": "2012-01-13T17:52:23.000+0000" }, { "id": "179318", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "Ti.Android.currentActivity will continue to only report the activity that is associated with a current context (url). This is not currently something that can be changed at the platform level without major impact to other areas. Ti.UI.Window.activity will continue to be the suggested mechanism for addressing this type of use case.", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2012-01-14T12:58:51.000+0000", "updated": "2012-01-14T12:58:51.000+0000" }, { "id": "179676", "author": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing bug. Verified fix on:\r\n\r\nSDK build: 1.9.0.v20120117144634\r\nRuntime: V8, Rhino\r\nTitanium Studio, build: 1.0.8.201201131907\r\nOS: Mac OS X Lion (10.7.1)\r\nDevice: Droid 3 (2.3.4)\r\n\r\nNote: To test, comment out *updateCurrentIntent* on line 58 from Hieu test code.\r\n", "updateAuthor": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-01-17T16:07:33.000+0000", "updated": "2012-01-17T16:31:36.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }