{ "id": "76891", "key": "AC-2857", "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": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-08-01T03:45:57.000+0000", "created": "2011-06-25T09:01:57.000+0000", "labels": [ "android" ], "versions": [], "issuelinks": [], "assignee": { "name": "tguntharp", "key": "tguntharp", "displayName": "Tony Guntharp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:47:48.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "When an Android application that uses Map View as a UI component is exited by the user using the 'Home' or 'Back' button does not always resume properly when reopened by the user. In the worst case ('Back' button) the application is forced closed by the Android OS (user is given a notification dialog). In the best case ('Home' button) the map view resumes but is missing the 'blue' current location map indicator flag. \r\n\r\nI have coded a fix for this issue in the 1.7.0 SDK and will create a fork and push the changes in a few days.\r\n\r\nThis problem only occurs on the device... not in the Android simulator. I am testing with an Samsung Infuse 4G.\r\n\r\n{code:title=app.js|borderStyle=solid}\r\n// this sets the background color of the master UIView (when there are no windows/tab groups on it)\r\nTitanium.UI.setBackgroundColor('#000');\r\n\r\n\r\nvar isAndroid = false;\r\n\r\nif (Titanium.Platform.name == 'android') {\r\n isAndroid = true;\r\n}\r\n\r\n\r\nif (Titanium.Geolocation.locationServicesEnabled===false) {\r\n Titanium.UI.createAlertDialog({\r\n title:'TC-105',\r\n message:'Please turn on location services.'\r\n }).show();\r\n}\r\n\r\nif (!isAndroid) {\r\n var authorization = Titanium.Geolocation.locationServicesAuthorization;\r\n Ti.API.info('Authorization: '+authorization);\r\n if (authorization == Titanium.Geolocation.AUTHORIZATION_DENIED) {\r\n Ti.UI.createAlertDialog({\r\n title:'TC=105',\r\n message:'You have disallowed TC-105 from running geolocation services.'\r\n }).show();\r\n } else if (authorization == Titanium.Geolocation.AUTHORIZATION_RESTRICTED) {\r\n Ti.UI.createAlertDialog({\r\n title:'TC-105',\r\n message:'Your system has disallowed TC-105 from running geolocation services.'\r\n }).show();\r\n }\r\n\r\n}\r\n\r\nTitanium.Geolocation.purpose = \"TC-105 Threat Level\";\r\nTitanium.Geolocation.preferredProvider = Titanium.Geolocation.PROVIDER_GPS;\r\n\r\n//\r\n// SET ACCURACY - THE FOLLOWING VALUES ARE SUPPORTED\r\n//\r\n// Titanium.Geolocation.ACCURACY_BEST\r\n// Titanium.Geolocation.ACCURACY_NEAREST_TEN_METERS\r\n// Titanium.Geolocation.ACCURACY_HUNDRED_METERS\r\n// Titanium.Geolocation.ACCURACY_KILOMETER\r\n// Titanium.Geolocation.ACCURACY_THREE_KILOMETERS\r\n//\r\nTitanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;\r\n\r\nTitanium.Geolocation.distanceFilter = 50;\r\n\r\n\r\n\r\n// create tab group\r\nvar tabGroup = Titanium.UI.createTabGroup();\r\n\r\n//\r\n// create base UI tab and root window\r\n//\r\nvar win1 = Titanium.UI.createWindow({\r\n title:'Tab 1',\r\n backgroundColor:'#fff'\r\n});\r\nvar tab1 = Titanium.UI.createTab({\r\n icon:'KS_nav_views.png',\r\n title:'Tab 1',\r\n window:win1\r\n});\r\n\r\nvar label1 = Titanium.UI.createLabel({\r\n color:'#999',\r\n text:'I am Window 1',\r\n font: {\r\n fontSize:20,\r\n fontFamily:'Helvetica Neue'\r\n },\r\n textAlign:'center',\r\n width:'auto'\r\n});\r\n\r\nwin1.add(label1);\r\n\r\n//\r\n// create controls tab and root window\r\n//\r\nvar win2 = Titanium.UI.createWindow({\r\n url:'MapView.js',\r\n title:'Tab 2',\r\n backgroundColor:'#fff'\r\n});\r\nvar tab2 = Titanium.UI.createTab({\r\n icon:'KS_nav_ui.png',\r\n title:'Tab 2',\r\n window:win2\r\n});\r\n\r\n//\r\n// add tabs\r\n//\r\ntabGroup.addTab(tab1);\r\ntabGroup.addTab(tab2);\r\n\r\n// open tab group\r\ntabGroup.open();\r\n{code}\r\n{code:title=MapView.js|borderStyle=solid}\r\nvar MapView = {\r\n};\r\n\r\n(function() {\r\n\r\n var mapView = null;\r\n var map = null;\r\n var isAndroid = false;\r\n\r\n function updateCurrentLocation(e) {\r\n Titanium.API.debug('updateCurrentLocation(e) - BEGIN');\r\n\r\n if (!e.success || e.error) {\r\n Ti.API.debug(\"Error: \"+e.error);\r\n } else {\r\n Ti.API.debug(\"e.coords.latitude: \" + e.coords.latitude);\r\n Ti.API.debug(\" e.coords.longitude: \" + e.coords.longitude);\r\n if(map !== null) {\r\n map.setLocation({\r\n latitude:e.coords.latitude,\r\n longitude:e.coords.longitude,\r\n animate:true\r\n });\r\n }\r\n }\r\n\r\n Titanium.API.debug('updateCurrentLocation(e) - END');\r\n }\r\n\r\n function updateMapRegion(e) {\r\n Titanium.API.debug('updateMapRegion(e) - BEGIN');\r\n\r\n Ti.API.debug('e.latitude = ' + e.latitude);\r\n Ti.API.debug('e.longitude = ' + e.longitude);\r\n\r\n Titanium.API.debug('updateMapRegion(e) - END');\r\n }\r\n\r\n function setInitialLocation(e) {\r\n\r\n Titanium.API.debug('setInitialLocation(e) - BEGIN');\r\n\r\n if (!e.success || e.error) {\r\n Ti.API.debug(\"Error: \"+e.error);\r\n return;\r\n }\r\n\r\n Titanium.API.info('geo - current location: ' + ' long ' + e.coords.latitude + ' lat ' + e.coords.longitude);\r\n\r\n if(map === null) {\r\n\r\n map = Titanium.Map.createView({\r\n mapType: Titanium.Map.STANDARD_TYPE,\r\n region: {\r\n latitude:e.coords.latitude,\r\n longitude:e.coords.longitude,\r\n latitudeDelta:0.007,\r\n longitudeDelta:0.007\r\n },\r\n animate:true,\r\n regionFit:true,\r\n userLocation:true\r\n });\r\n\r\n mapView.add(map);\r\n\r\n mapView.addEventListener('regionChanged', updateMapRegion);\r\n Titanium.Geolocation.addEventListener('location', updateCurrentLocation);\r\n\r\n } else {\r\n updateCurrentLocation(e);\r\n }\r\n\r\n Titanium.API.debug('setInitialLocation(e) - END');\r\n\r\n }\r\n\r\n function configureAppListeners() {\r\n Titanium.API.debug('configureAppListeners() - BEGIN');\r\n\r\n if (isAndroid) {\r\n // as the destroy handler will remove the listener, only set the pause handler to remove if you need battery savings\r\n Ti.Android.currentActivity.addEventListener('pause', function(e) {\r\n Ti.API.info(\"pause event received\");\r\n\r\n Titanium.Geolocation.removeEventListener('location', updateCurrentLocation);\r\n if(mapView !== null) {\r\n mapView.removeEventListener('regionChanged', updateMapRegion);\r\n }\r\n });\r\n Ti.Android.currentActivity.addEventListener('resume', function(e) {\r\n Ti.API.info(\"resume event received\");\r\n\r\n Titanium.Geolocation.addEventListener('location', updateCurrentLocation);\r\n if(mapView !== null) {\r\n mapView.addEventListener('regionChanged', updateMapRegion);\r\n }\r\n });\r\n Ti.Android.currentActivity.addEventListener('resumed', function(e) {\r\n Ti.API.info(\"resumed event received\");\r\n\r\n Titanium.Geolocation.addEventListener('location', updateCurrentLocation);\r\n if(mapView !== null) {\r\n mapView.addEventListener('regionChanged', updateMapRegion);\r\n }\r\n });\r\n } else {\r\n Titanium.App.addEventListener('pause', function(e) {\r\n Ti.API.info(\"pause event received\");\r\n });\r\n Titanium.App.addEventListener('resume', function(e) {\r\n Ti.API.info(\"resume event received\");\r\n });\r\n Titanium.App.addEventListener('resumed', function(e) {\r\n Ti.API.info(\"resumed event received\");\r\n });\r\n }\r\n\r\n Titanium.API.debug('configureAppListeners() - END');\r\n\r\n }\r\n\r\n function initializeThreatMap() {\r\n Titanium.API.debug('ThreatMapView.createThreatMap() - BEGIN');\r\n\r\n if (Titanium.Platform.name == 'android') {\r\n isAndroid = true;\r\n }\r\n\r\n configureAppListeners();\r\n\r\n if(Titanium.Platform.model == 'Simulator' || Titanium.Platform.model == \"sdk\" || Titanium.Platform.model == \"google_sdk\") {\r\n var coords = {\r\n latitude: 39.4316215,\r\n longitude: -119.7709939\r\n };\r\n var e = {\r\n coords: coords,\r\n success: true,\r\n error:''\r\n };\r\n setInitialLocation(e);\r\n } else {\r\n Titanium.Geolocation.getCurrentPosition( setInitialLocation );\r\n }\r\n\r\n Titanium.API.debug('ThreatMapView.createThreatMap() - END');\r\n }\r\n\r\n MapView.createMapView = function(args) {\r\n\r\n mapView = Titanium.UI.createView({\r\n backgroundColor:'#fff'\r\n });\r\n\r\n initializeThreatMap();\r\n\r\n return mapView;\r\n };\r\n})();\r\nTitanium.UI.currentWindow.add(MapView.createMapView());\r\n{code}\r\n\r\n", "attachment": [ { "id": "21461", "filename": "TC_105_Use_Case.zip", "author": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-06-26T08:19:04.000+0000", "size": 2556082, "mimeType": "application/zip" } ], "flagged": false, "summary": "Android: Map View state handling when app goes into background with 'Home' or 'Back' button is not opitmal", "creator": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "* Titanium Mobile 1.7.0 using the UIMapView component.\r\n* Android version: Google APIs Android 2.2 \r\n* Titanium SDK version: 1.7.1 (06/21/11 14:28 1293a6d)", "comment": { "comments": [ { "id": "157790", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "In order for us to progress this issue, please edit your ticket to include a proper [use-case|http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-CreatingGoodUsecases].\r\n\r\nPlease state the Android version you have tested. If testing using an emulator, ensure you are *not* using 2.3.X, due to the problems explained elsewhere.\r\n\r\nPlease state your Titanium build date and hash, which is output to the console before an app is launched.\r\n\r\nAlso kindly read the [Submitting Bug Reports|http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-SubmittingBugReports] guide before raising tickets.\r\n\r\nThank you", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-06-25T12:11:57.000+0000", "updated": "2011-06-25T12:11:57.000+0000" }, { "id": "157809", "author": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I have a use-case in process.\r\n\r\n\r\nThe Submitting Bug Reports guide refers to a bug tracking system named \"Lighthouse\" is that still in use or is Jira the correct place to file bugs?\r\n\r\nhttp://developer.appcelerator.com/question/121625/android-uimapview-issues\r\n\r\nI have updated the Environment to include the Android version and the Titanium SDK version.\r\nAlso, I've attached a \"use-case code\" example that reproduces the problem. The behavior described in this bug does not happen in the simulator only on an Android device.", "updateAuthor": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-06-26T07:56:59.000+0000", "updated": "2011-06-26T08:25:25.000+0000" }, { "id": "157971", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Thank you for the updated information, Joe - the ticket is much better. :) I tried to run the project, but it failed due to a problem with MapView.js. See http://pastebin.com/7cqVvUp9 . If you can't see what the error is, I will have time to debug it on Thursday. Once we can reproduce the issue here, we can pull your code (thank you for your obvious efforts with that also, btw).", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-06-28T18:03:07.000+0000", "updated": "2011-06-28T18:03:07.000+0000" }, { "id": "157974", "author": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Nothing in the stack trace looks familiar. I disabled Fastdev on my Mac as it was causing build issues. \r\n\r\nI've been testing my the changes I made for over a week without any issues. I have very little experience with the Android SDK and have little doubt that improvements can be made to the code. I'm planning on distributing the app in less than a week with the changes. Hopefully a fix is pushed into the master before too long.", "updateAuthor": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-06-28T19:06:38.000+0000", "updated": "2011-06-28T19:06:38.000+0000" }, { "id": "160398", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Joe\r\n\r\nI cannot progress this without a working usecase. Are you able to supply it? Note that the guide at [Submitting Bug Reports|http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-SubmittingBugReports] has now been corrected.", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-07-23T06:34:02.000+0000", "updated": "2011-07-23T06:34:02.000+0000" }, { "id": "160399", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Joe\r\n\r\nPlease do not attach a whole project - the usecase needs to be simplified and added as a single (if possible) code block in the main body of this ticket.\r\n\r\nThanks", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-07-23T06:36:20.000+0000", "updated": "2011-07-23T06:36:20.000+0000" }, { "id": "160400", "author": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I've inserted the code for the app.js and MapView.js files into the Description section of this ticket. The files are marked with:\r\n\r\n==========================================================\r\nBEGIN/END File: XXXXX.js\r\n==========================================================\r\n\r\nI hope this helps.\r\n\r\n", "updateAuthor": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-07-23T06:48:37.000+0000", "updated": "2011-07-23T06:48:37.000+0000" }, { "id": "160436", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-07-25T01:44:26.000+0000", "updated": "2011-07-25T01:44:26.000+0000" }, { "id": "160708", "author": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Paul,\r\n\r\nI've updated the Use Case code with the appropriate markdown tags.\r\n\r\n-Joe", "updateAuthor": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-07-26T21:13:00.000+0000", "updated": "2011-07-26T21:13:00.000+0000" }, { "id": "160729", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Joe\r\n\r\nThanks - the ticket looks much better. Do you have a trace log of the exception? Would you include that in a code block also?\r\n\r\nThanks", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-07-27T08:49:09.000+0000", "updated": "2011-07-27T08:49:09.000+0000" }, { "id": "161251", "author": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Okay... I updated to 1.7.2 and the \"force close\" issue is no longer present - no stack trace now. However, the missing \"blue\" current location map indicator flag is well... still missing on app resume.", "updateAuthor": { "name": "izenme", "key": "izenme", "displayName": "Joe Chavez", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-07-30T06:31:24.000+0000", "updated": "2011-07-30T06:31:24.000+0000" }, { "id": "161265", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-08-01T03:45:57.000+0000", "updated": "2011-08-01T03:45:57.000+0000" }, { "id": "168237", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Closing due to inactivity.", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-10-07T05:48:01.000+0000", "updated": "2011-10-07T05:48:01.000+0000" } ], "maxResults": 13, "total": 13, "startAt": 0 } } }