I\'m creating an app using flash cc. I needed storage permission. It turns out I needed to ask user the permission for using storage devices. I can ask user for permission a
Finally, I figured it out. Prerequisites:
Then, this code works for me just fine, it displays Android's "Grant Permission" dialog and then outputs GRANTED or DENIED with regard to my choice. The Log class is just a debug panel of my own, you can change Log.log calls to trace or grab it here (it has no dependencies): https://bitbucket.org/thydmitry/ru.delimiter/src/9083fb46ce1c/classes/ru/delimiter/utils/
package
{
import ru.delimiter.utils.Log;
import flash.filesystem.File;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.PermissionEvent;
import flash.permissions.PermissionStatus;
public class Permissions extends Sprite
{
private var F:File;
public function Permissions()
{
if (stage) onStage();
else addEventListener(Event.ADDED_TO_STAGE, onStage);
}
private function onStage(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, onStage);
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
Log.create(this, true);
Log.log("[Permissions Test] started");
Log.log("File.permissionStatus:", File.permissionStatus);
F = File.applicationStorageDirectory.resolvePath("somefile.txt");
F.addEventListener(PermissionEvent.PERMISSION_STATUS, onPerm);
stage.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(e:MouseEvent):void
{
F.requestPermission();
}
private function onPerm(e:PermissionEvent):void
{
Log.log("User's decision:", e.status.toUpperCase());
}
}
}