Start Android Activity and wait for result

I want to start an Android activity that read qr code and use the resulting string in the OpenFL Android application (the launcher). How can i do that?

Follow a tutorial that describes how to implement this in Java, then use JNI to call the Java function from Haxe. (Clearer instructions here.)

To return the result, you can either poll regularly (make another JNI function called getQRResult() and call that every second or so), or you can use this. If you go with the latter, note that JNI is now openfl.utils.JNI, and HaxeObject is now org.haxe.lime.HaxeObject.

You can use a template to include the Java source file in your app:

<template path="path/to/" rename="src/com/example/packagename/" />

Thanks. I will be appliying it soon.

I am having the same issue now, I want to get the result from a startActivityForResult call but the above link for not making use of the poll object is lost.

Anyone has any idea to get back the result from an Android Activity?

After some researching I have found HaxeObject class that you can use in Java and makes life much easier to integrate Haxe with Java.

import org.haxe.lime.HaxeObject;

For other people who can be interested I leave this topic where you can find some good advices and code.

1 Like