Skip to main content
Known Participant
April 19, 2017
Answered

Unable to set STORAGE permissions - AIR 24 SDK - Android 6xx

  • April 19, 2017
  • 2 replies
  • 2386 views

Hi everyone, STORAGE is unknown. What is the right syntax for the STORAGE permission?

import flash.events.PermissionEvent;

import flash.permissions.PermissionStatus;

if (STORAGE.permissionStatus != PermissionStatus.GRANTED) {

     // do some things

} else {

     // request permission

    STORAGE.requestPermission();

}

This topic has been closed for replies.
Correct answer Colin Holgate

Oh sorry, I posted wrong code. DO you mean something like this:

var needstorage:File = ???;

if (File.permissionStatus != PermissionStatus.GRANTED) {

    needstorage.addEventListener(PermissionEvent.PERMISSION_STATUS, function (e: PermissionEvent): void {

        if (e.status == PermissionStatus.GRANTED) {

            MovieClip(root).play();

        } else {

            // permission denied

        }

    });

    try {

        needstorage.requestPermission();

    } catch (e: Error) {

        // another request is in progress

    }

} else {

     stop();

     needstorage.requestPermission();

}


In the other person's code they have this line:

var infoFile:File = obbDir.resolvePath(fileName);

That's more complicated than you're needs, in that they had an OBB files that had been extracted. This article gives some other examples, like the user's home directory. I don't know what folder you're going to try to write to, but perhaps the applicationStorageDirectory is the right one. That would give you lines like:

var needstorage:File = File.applicationStorageDirectory;

needstorage = needstorage.resolvePath("prefs.xml");

needstorage.addEventListener(PermissionEvent.PERMISSION_STATUS, function (etc)...

The 'prefs.xml' could be the name of the file you intend to write.

2 replies

chasblnAuthor
Known Participant
April 20, 2017

I tried to used this in first frame. But the request doesn't work... any ideas? I use latest CC 2017 and AIR 25.

import flash.events.PermissionEvent;

import flash.permissions.PermissionStatus;

var needstorage:File;

if (File.permissionStatus != PermissionStatus.GRANTED) {

    storagezugriff.addEventListener(PermissionEvent.PERMISSION_STATUS, function (e: PermissionEvent): void {

        if (e.status == PermissionStatus.GRANTED) {

            MovieClip(root).play();

        } else {

            // permission denied

        }

    });

    try {

        needstorage.requestPermission();

    } catch (e: Error) {

        // another request is in progress

    }

} else {

     stop();

     needstorage.requestPermission();

}

Colin Holgate
Inspiring
April 20, 2017

If you look at the other page code, infoFile is a File object. In your code storagezugriff would need to have been set up to point to the right location.

chasblnAuthor
Known Participant
April 20, 2017

Oh sorry, I posted wrong code. DO you mean something like this:

var needstorage:File = ???;

if (File.permissionStatus != PermissionStatus.GRANTED) {

    needstorage.addEventListener(PermissionEvent.PERMISSION_STATUS, function (e: PermissionEvent): void {

        if (e.status == PermissionStatus.GRANTED) {

            MovieClip(root).play();

        } else {

            // permission denied

        }

    });

    try {

        needstorage.requestPermission();

    } catch (e: Error) {

        // another request is in progress

    }

} else {

     stop();

     needstorage.requestPermission();

}

Anki_AG_
Adobe Employee
Adobe Employee
April 20, 2017

Please refer to Release Notes Flash Player 24 AIR 24  for details regarding permission support in Adobe AIR.

Thanks,

Ankit | Adobe AIR Engineering

Colin Holgate
Inspiring
April 20, 2017

I looked in the release notes, and in linked Google sites, and couldn't find anything about storage.

But I found posts like this one:

AIR 24 File.requestPermission throws error #1069 on Android 6.0.1

which suggests that you would use File.permissionStatus