Critical problem with registerActivityResultHandler( OnActivityResultHandler handler )

Hello, I’m Songinnight.

We using some outer modules. (Game publisher’s module or Ad. modules… like that…)

Critical issue is that we cannot receive onActivityResult event.

Because some modules callback startActivity with very high requestCode number. For example, 5901, 60001, 405… I do not run startActivityForResult(…). Module does. I cannot handle activity which is added by module.

Therefore, I think there must be single onActivityResult handler, could handle every request codes. At least enough to know there’s activityResult event occured.

I’m begging you.

Have a good day today. Thank you.

Bellow my example code…

[CoronaActivity Class]

... private HashMap\<Integer, OnActivityResultHandler\> fActivityResultHandlers; // existing handler array private static OnActivityResultHandler fActivityResultSingleHandlers; // \<--- single static handler ... public CoronaActivity() { myInitialIntent = null; myIsActivityResumed = false; ... myRuntimeTaskDispatcher = null; fActivityResultHandlers = new HashMap(); fActivityResultSingleHandlers = null; // \<--- init. } ... // I suggest this public void registerActivityResultSingleHandler(OnActivityResultHandler handler) { if (handler == null) { Log.e(...) return; } // register one handler fActivityResultSingleHandlers = handler; } ... protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // ------- We can get any requestCode and I will be able to sleep comfortably :) ------- if( fActivityResultSingleHandlers != null) { fActivityResultSingleHandlers( requestCode, resultCode, data ); } // -------------------------------------- OnActivityResultHandler handler = null; handler = (OnActivityResultHandler)fActivityResultHandlers.get(Integer.valueOf(requestCode)); if (handler == null) { return; } handler.onHandleActivityResult(this, requestCode, resultCode, data); }&nbsp;

Sorry, I posted in wrong category.

Finally I figured out that CoronaActivity is singleTask and singleTask (or singleInstance) activity cannot fire onActivityResult. :frowning:

ex) android:launchMode=“singleTask”

Then, how can I get activity result without creating another activity?

In my case, request code is random number what is thrown by module.

I’m going to move this to Enterprise for you.

I’m not sure what problems you are running into.  Can you provide more details?

Several enterprise developers have been able to use our OnActivityResultHandler just fine.  This include some of our 3rd party plugins.  We also use it internally in our own core Corona code such as for photo picking and camera shot taking with our media.show() API… as well as for facebook logins and Google game service dialog selections.  In all these cases, we register an OnActivityResultHandler() to acquire a request code and sometimes hand over that code to the library to launch the intent.

Have a look at the example I’ve posted via the link below.  Note that I unregister the handler once it has been called.  This frees up the request code for the next handler.

   http://forums.coronalabs.com/topic/37282-how-can-one-capture-cameragallery-return-result-in-android-native-code/?p=193386

The idea is to register an onActivityResult() handler just before you launch an intent.  The idea is that you are binding one handler to one specific operation… rather than a global handler that receives all results like how Google designed it.  It’s a safety mechanism that we’ve implemented to help prevent Corona plugins from accidentally handling results that don’t belong to it.  It actually works quite well.  The only time your handler will not get called is if the CoronaActivity gets destroyed, in which case, not even the activity’s onActivityResult() method gets called.

Sorry, I posted in wrong category.

Finally I figured out that CoronaActivity is singleTask and singleTask (or singleInstance) activity cannot fire onActivityResult. :frowning:

ex) android:launchMode=“singleTask”

Then, how can I get activity result without creating another activity?

In my case, request code is random number what is thrown by module.

I’m going to move this to Enterprise for you.

I’m not sure what problems you are running into.  Can you provide more details?

Several enterprise developers have been able to use our OnActivityResultHandler just fine.  This include some of our 3rd party plugins.  We also use it internally in our own core Corona code such as for photo picking and camera shot taking with our media.show() API… as well as for facebook logins and Google game service dialog selections.  In all these cases, we register an OnActivityResultHandler() to acquire a request code and sometimes hand over that code to the library to launch the intent.

Have a look at the example I’ve posted via the link below.  Note that I unregister the handler once it has been called.  This frees up the request code for the next handler.

   http://forums.coronalabs.com/topic/37282-how-can-one-capture-cameragallery-return-result-in-android-native-code/?p=193386

The idea is to register an onActivityResult() handler just before you launch an intent.  The idea is that you are binding one handler to one specific operation… rather than a global handler that receives all results like how Google designed it.  It’s a safety mechanism that we’ve implemented to help prevent Corona plugins from accidentally handling results that don’t belong to it.  It actually works quite well.  The only time your handler will not get called is if the CoronaActivity gets destroyed, in which case, not even the activity’s onActivityResult() method gets called.