androidactionscript-3airstarling-framework

Adobe AIR CameraRoll can't select photo on Android 6.0


I'm having some issues with uploading images with media promise as described here.

The problem is after updating the phone to new Android 6.0 the Async image never loads anymore, in the following code, listener is added to eventSource but onMediaLoaded never fires. Before the update everything worked perfectly:

private function imageSelected(event:MediaEvent):void {

    trace( "Media selected..." );
    var imagePromise:MediaPromise = event.data;
    dataSource = imagePromise.open();

    if( imagePromise.isAsync )
    {

        trace( "Asynchronous media promise." );

        var eventSource:IEventDispatcher = dataSource as IEventDispatcher;
        eventSource.addEventListener( Event.COMPLETE, onMediaLoaded );

    }
    else
    {
        trace( "Synchronous media promise." );
        readMediaData();
    }


}

Among other permissions, I have these in the descriptor:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Any idea how to fix this?

EDIT:

i also tried to load the promise like this, but got exactly same result:

var loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMediaLoaded );
loader.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, onError);
loader.loadFilePromise(imagePromise);

Solution

  • In Android 6.0 (v23) they introduced runtime permissions where you have to ask the user for permission to access certain "dangerous" permissions.

    The problem will be that Adobe haven't added this permission request to the media loading method you are using.

    There are 2 ways around this, as I suggested in the comment, set your target sdk to be an older version. This will tell Android that your application doesn't support any of the 6.0+ features and should rely on the older permission model.

    The other is to grab an ANE to request the required permissions when you need them. Eg you can use the Permissions ANE from us:

    http://airnativeextensions.com/extension/com.distriqt.Permissions

    Use that method if you require any of the Android 6.0 features to be used in your app.