{ "id": "172742", "key": "TIMOB-26752", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": null, "resolutiondate": null, "created": "2018-12-14T05:25:46.000+0000", "priority": null, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-01-28T22:16:15.000+0000", "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" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Currently we have onCreate, onPause, onResume, etc callback methods available for an activity, but we do not have any *onActivityResult* callback method due to which many things are not doable easily and straight-forward in Titanium.\r\n\r\ne.g.\r\n1- Google Location API library allows to enable location from within the app itself without going into the device settings. But this API call returns the result in native *onActivityResult* method.\r\n2- Some image-cropping or scanner libraries' results are returned in native *onActivityResult* method. (https://github.com/ArthurHub/Android-Image-Cropper)\r\n\r\nAt present, we cannot achieve this without creating modules which is cumbersome when we already have Hyperloop. \r\n\r\nWith Hyperloop we can call native *startActivityForResult* method on third-party libraries but we cannot get their results back to the activity as Hyperloop is unable to let us define *TiActivityResultHandler* interface methods nor we can cast a native Intent to Titanium intent so we can use Titanium's *startActivityForResult* method callback.\r\n\r\nIt makes Hyperloop less usable if anything is to be returned in `onActivityResult` method. We hope to see this improvement in SDK 8.x.x itself as it will give more flexibilities in using Hyperloop.", "attachment": [], "flagged": false, "summary": "Android: Add support for `onActivityResult` callback method for activity", "creator": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "444611", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Alternatively, you can use Titanium's {{Ti.Android.Activity.startActivityForResult()}} JavaScript method. It's 2nd argument accepts a callback which will be called by Titanium's internal {{onActivityResult()}} method.\r\nhttps://docs.appcelerator.com/platform/latest/#!/api/Titanium.Android.Activity-method-startActivityForResult\r\n\r\nAre you able to use this approach instead?", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-12-14T19:07:19.000+0000", "updated": "2018-12-14T19:07:41.000+0000" }, { "id": "444627", "author": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-12-15T13:17:29.000+0000", "updated": "2018-12-15T13:17:29.000+0000" }, { "id": "445501", "author": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "body": "I have the same issue with a third party SDK.\r\n\r\nThe interace calls a methd with one paramter (currentActivity) and send the result to onActivityResult...\r\n\r\nThe SDK opens a new activity by Fidel.present(TiApplication.getInstance().getCurrentActivity());\r\nhttps://github.com/FidelLimited/fidel-android\r\n\r\nNeed support.\r\n\r\n", "updateAuthor": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-01-20T21:25:47.000+0000", "updated": "2019-01-20T21:25:47.000+0000" }, { "id": "445503", "author": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "body": "I cannot use `startActivityForResult()` because the SDK only exports the method for opening the new activity, the activity self is private and I have no access. Is there a solution without patch of Titanium SDK?", "updateAuthor": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-01-20T22:40:24.000+0000", "updated": "2019-01-20T22:40:24.000+0000" }, { "id": "445676", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Any update here? I am trying to use the [Matisse|https://github.com/zhihu/Matisse/] library which returns data via this callback. I tried hooking into the lifecycle like Ti.Facebook does [here|https://github.com/appcelerator-modules/ti.facebook/blob/master/android/src/facebook/ActivityWorkerProxy.java#L51], but it doesn't seem to be called.\r\n\r\nUnfortunately, the {{public void onCreate(Activity activity, Bundle savedInstanceState)}} signature is only available in {{KrollProxy}} instances, not {{KrollModule}} ones. So I used {{public void onStart(Activity activity)}} there, but it doesn't get called either. My code:\r\n\r\n{code:java}\r\n@Override\r\npublic void onStart(Activity activity)\r\n{\r\n\t((TiBaseActivity) activity).addOnActivityResultListener(this);\r\n}\r\n\r\n@Override\r\npublic void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data)\r\n{\r\n\tLog.w(LCAT, \"onActivityResult called\");\r\n}\r\n{code}\r\nMy class {{implements}} both {{OnActivityResultEvent}} and {{OnInstanceStateEvent}}. \r\n\r\n*EDIT*: Found a proper way!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-01-27T13:06:33.000+0000", "updated": "2019-01-27T13:40:09.000+0000" }, { "id": "445677", "author": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "body": "If onCreate is only available for proxies then we could implement the interface in a proxy. I implemented Ti.Paypal with this pattern.\r\n\r\nIn my project I decompiled the aar, found the name of new activity and used it in `launchActivityForResult`\r\n\r\n\r\n{code:java}\r\n@Kroll.method\r\npublic void present() {\r\n\tfinal TiActivitySupport support = (TiActivitySupport) TiApplication.getAppCurrentActivity();\r\n\tfinal Intent intent = new Intent(TiApplication.getInstance().getApplicationContext(),\r\n\t\t\tEnterCardDetailsActivity.class);\r\n\tFidel.FIDEL_LINK_CARD_REQUEST_CODE = support.getUniqueResultCode();\r\n\t\t\tsupport.launchActivityForResult(intent, Fidel.FIDEL_LINK_CARD_REQUEST_CODE, this);\r\n}\r\n{code}\r\n\r\nand\r\n\r\n{code:java}\r\npublic class TifidelModule extends KrollModule implements TiActivityResultHandler { ……… }\r\n{code}\r\n\r\nand \r\n{code:java}\r\n@Override\r\npublic void onResult(Activity dummy, int requestCode, int resultCode, Intent data) {\r\n\tif (requestCode == Fidel.FIDEL_LINK_CARD_REQUEST_CODE) {\r\n\t\tif (data != null && data.hasExtra(Fidel.FIDEL_LINK_CARD_RESULT_CARD)) {\r\n\t\t\tLinkResult card = (LinkResult) data.getParcelableExtra(Fidel.FIDEL_LINK_CARD_RESULT_CARD);\r\n\t\t\tHashMap event = new HashMap();\r\n\t\t\tevent.put(\"accountId\", card.accountId);\r\n }\r\n }\r\n}\r\n\r\n{code}\r\n\r\n ", "updateAuthor": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-01-27T13:39:39.000+0000", "updated": "2019-01-27T13:39:39.000+0000" }, { "id": "445678", "author": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "body": "What I have understood:\r\n\r\nYou try to add this listener in onStart, but it will not called.\r\n", "updateAuthor": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-01-27T13:42:05.000+0000", "updated": "2019-01-27T13:45:23.000+0000" }, { "id": "445709", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Let's not hijack [~prashant_saini]'s ticket please. It might cause confusion.\r\n\r\nThis ticket is about doing this 100% in JavaScript and hyperloop, without having to write any Java code. [~hknoechel], [~titanium@webmasterei-hamburg.de], it looks like you 2 are coding in Java... in which case, there is a solution available to you now. [~titanium@webmasterei-hamburg.de], I believe I've already helped you in ticket [AC-6111]? If not, perhaps we can continue our conversation there if you don't mind. [~hknoechel], perhaps what I've written there might help you too, but it sounds like you have already solved it. (I'm recommending that you use \"ti.barcode\" as an example since it's simpler.)\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-28T19:28:32.000+0000", "updated": "2019-01-28T19:28:32.000+0000" }, { "id": "445716", "author": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "body": "My issue is solved because I could read the class name from decompiled jar. Sorry for \"hijacking\" this was not my intrention.", "updateAuthor": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-01-28T20:04:23.000+0000", "updated": "2019-01-28T20:04:23.000+0000" }, { "id": "445719", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "No worries. :)", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-28T22:16:15.000+0000", "updated": "2019-01-28T22:16:15.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }