{ "id": "173447", "key": "AC-6202", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2019-06-10T23:45:24.000+0000", "created": "2019-04-07T16:46:47.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2021-02-02T14:08:00.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": [], "description": "In my com.locationservices module I can't get onActivityResult by using TiActivitySupport because it doesn't support startResolutionForResult void from ResolvableApiException\r\n\r\nhttps://github.com/AhmedMSayed/TiLocationServices/blob/master/android/src/com/locationservices/LocationservicesModule.java", "attachment": [], "flagged": false, "summary": "Android: TiActivitySupport support startResolutionForResult", "creator": { "name": "ahmed.mohamed20320", "key": "ahmed.mohamed20320", "displayName": "Ahmed Mohamed", "active": true, "timeZone": "Africa/Cairo" }, "subtasks": [], "reporter": { "name": "ahmed.mohamed20320", "key": "ahmed.mohamed20320", "displayName": "Ahmed Mohamed", "active": true, "timeZone": "Africa/Cairo" }, "environment": null, "comment": { "comments": [ { "id": "447552", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello [~ahmed.mohamed20320], Can you share some native guide on how this is handled in there? Thanks. ", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2019-04-09T17:54:48.000+0000", "updated": "2019-04-09T17:54:48.000+0000" }, { "id": "447578", "author": { "name": "ahmed.mohamed20320", "key": "ahmed.mohamed20320", "displayName": "Ahmed Mohamed", "active": true, "timeZone": "Africa/Cairo" }, "body": "ResolvableApiException provides a method to resolves an error by starting any intents requiring user interaction. [See Description here|https://developers.google.com/android/reference/com/google/android/gms/common/api/ResolvableApiException]\r\n\r\nstartResolutionForResult is a method like startActivityForResult method which used to start an activity and wait for a result that will be catched later in onActivityResult method.\r\n\r\nAt now Titanium support startActivityForResult by using launchActivityForResult method in TiActivitySupport and catched the results by onResult\r\n\r\nSo we need to support startResolutionForResult to get its results too in onResult\r\n\r\nYou can test it on my module [here|https://github.com/AhmedMSayed/TiLocationServices/blob/5a46495ee567d6ca91a8cc727a21dbd0f5146651/android/src/com/locationservices/LocationservicesModule.java#L137]", "updateAuthor": { "name": "ahmed.mohamed20320", "key": "ahmed.mohamed20320", "displayName": "Ahmed Mohamed", "active": true, "timeZone": "Africa/Cairo" }, "created": "2019-04-10T04:19:59.000+0000", "updated": "2019-04-10T04:19:59.000+0000" }, { "id": "447579", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is possible to do now. Instead of using the {{TiActivitySupportHelper.launchActivityForResult()}} method, you'll want to create your own version of that code. You'll need to create your own {{TiActivityResultHandler}} object, pass it into the {{TiActivitySupportHelper.registerResultHandler()}} method (which Titanium's activity queries in its {{onActivityResult()}} method, and then call the {{startResolutionForResult()}} with the request code and activity you are launching it from.\r\n\r\nI can write up a code example tomorrow.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-04-10T05:16:52.000+0000", "updated": "2019-04-10T05:16:52.000+0000" }, { "id": "447603", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "In your code, get rid of this part...\r\n{code:java}\r\nresolvable.startResolutionForResult(TiApplication.getAppRootOrCurrentActivity(), REQUEST_CHECK_SETTINGS);\r\n{code}\r\n\r\nAnd do this instead...\r\n{code:java}\r\n// Add these imports to the top...\r\n#import org.appcelerator.titanium.TiBaseActivity;\r\n#import org.appcelerator.titanium.TiLifecycle;\r\n{code}\r\n{code:java}\r\n// Replace your startResolutionForResult() line with the below...\r\norg.appcelerator.titanium.TiBaseActivity activity = TiApplication.getAppRootOrCurrentActivity();\r\nif (activity != null) {\r\n\tfinal int MY_REQUEST_CODE = activity.getUniqueResultCode();\r\n\tfinal resultListener = new org.appcelerator.titanium.TiLifecycle.OnActivityResultEvent() {\r\n\t\t@Override\r\n\t\tpublic void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {\r\n\t\t\t// This listener is invoked for all request codes. So, ignore the ones not directed to us.\r\n\t\t\tif (requestCode != MY_REQUEST_CODE) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// This is our request code.\r\n\t\t\t// Handle the result code returned by startResolutionForResult() here.\r\n\t\t}\r\n\t};\r\n\tactivity.addOnActivityResultListener(resultListener); // <- Stores listener as weak reference.\r\n\tresolvable.startResolutionForResult(activity, MY_REQUEST_CODE);\r\n}\r\n{code}\r\n\r\nUnfortunately our Titanium activity's {{addOnActivityResultListener()}} method stores the listener as a weak reference. So, you need to hold on to the listener as a strong reference temporarily via {{final}}. I'm doing it by boxing it above. Alternatively, you can implement the {{OnActivityResultEvent}} via your {{LocationservicesModule}} class but then you have to change the request code handling.\r\n\r\nI hope this helps!", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-04-10T19:43:37.000+0000", "updated": "2019-04-10T19:43:37.000+0000" }, { "id": "448283", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello [~ahmed.mohamed20320], Can you follow up here? what's the status of your issue? did you try Han's guide?", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2019-05-09T23:20:15.000+0000", "updated": "2019-05-09T23:20:26.000+0000" }, { "id": "458133", "author": { "name": "ahmed.mohamed20320", "key": "ahmed.mohamed20320", "displayName": "Ahmed Mohamed", "active": true, "timeZone": "Africa/Cairo" }, "body": "Thanks @Joshua Quick it works like a charm.\r\n\r\nhttps://github.com/AhmedMSayed/ti.locationservices/blob/7d65d126e43c1bf600530ee4a0c841c850fe4388/android/src/ti/locationservices/TiLocationservicesModule.java#L120", "updateAuthor": { "name": "ahmed.mohamed20320", "key": "ahmed.mohamed20320", "displayName": "Ahmed Mohamed", "active": true, "timeZone": "Africa/Cairo" }, "created": "2021-02-02T14:08:00.000+0000", "updated": "2021-02-02T14:08:00.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }