native extension: how to startActivityForResult or use a JS-Callbacks

T Tobias Kiefer 3 years 5 months ago
9 1 0

Hello everyone,

I am trying to write my own native extension for scanning barcodes (as Rho.Barcode does not work with ITF Codes on image based scanners).

From javascript I call a method called take(). This method then calls startActivity() on the RhodesActivity. Now my Decoding app starts, I can scan the barcode and thats it.
The Problem now is, that my original take method returns almost immediately and therefore setting the method result does not work.

I already tried to force the take() call to stay open by using a wait() notify() mechanism until my Decoding Activity sets the result and only then return. The problem with this approach is that as take() does not return right away the screen stays black and I do not even see the Decoding app.

Is there a possibility to simply call startActivityForResult() as in a normal android app and only return from the js call to take() once the onActivityResult() has finished?

Or alternatively, how could I give a js callback to my take() method and call it when I am done? I read the documentation on this but there is no example and I did not know how to get it running.

Best regards,
Tobi

Please Register or Login to post a reply

1 Replies

C Chris Child

I'm running into almost the exact same problem. I'm implementing a barcode scan as well and I've read how to introduce callbacks but without an actual example I have no idea how it actually works. Did you ever come to a working solution?

Thanks

Chris

CONTACT
Can’t find what you’re looking for?