How to receive response from ActivityCompat.requestPermissions running in Adobe Native Extension (ANE) context?
05:38 20 Oct 2016

I'm trying to implement askForPermisions function as an Adobe Native Extension (ANE) for AIR. My function is now defined as:

public class APKaskForPermission implements FREFunction  {
    public static final String TAG = "askForPermission";
    @Override
    public FREObject call(FREContext ctx, FREObject[] passedArgs) {
        FREObject result = null;
        String permission;
        Integer requestCode;

        try{
            permission = passedArgs[0].getAsString();
            requestCode = passedArgs[1].getAsInt();

            if (ContextCompat.checkSelfPermission(NativeExtension.appContext, permission) != PackageManager.PERMISSION_GRANTED) {

                // Should we show an explanation?
                if (ActivityCompat.shouldShowRequestPermissionRationale(ctx.getActivity(), permission)) {
                    Log.d(TAG, "shouldShowRequestPermissionRationale: " + permission);
                    //This is called if user has denied the permission before
                    //In this case I am just asking the permission again
                    Log.d(TAG, "requestPermissions: " + permission);
                    ActivityCompat.requestPermissions(ctx.getActivity(), new String[]{permission}, requestCode);

                } else {
                    Log.d(TAG, "requestPermissions: " + permission);
                    ActivityCompat.requestPermissions(ctx.getActivity(), new String[]{permission}, requestCode);
                }
                result = FREObject.newObject(false);
            } else {
                Log.d(TAG, "" + permission + " is already granted.");
                //Toast.makeText(this, "" + permission + " is already granted.", Toast.LENGTH_SHORT).show();
                result = FREObject.newObject(true);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

        return result;
    }
}

This display the dialog as expected, but I cannot find what to do to get the response, as all examples on the web define it in the MainActivity source, but I'm in the native extension context.

Any help?

android air air-native-extension ane