Highlighted

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

Explorer ,
Apr 19, 2017

Copy link to clipboard

Copied

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();

}

Adobe Community Professional
Correct answer by Colin Holgate | Adobe Community Professional

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.

TOPICS
Development

Views

1.7K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

Explorer ,
Apr 19, 2017

Copy link to clipboard

Copied

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();

}

Adobe Community Professional
Correct answer by Colin Holgate | Adobe Community Professional

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.

TOPICS
Development

Views

1.7K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 19, 2017 0
Adobe Employee ,
Apr 20, 2017

Copy link to clipboard

Copied

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

Thanks,

Ankit | Adobe AIR Engineering

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 20, 2017 0
Adobe Community Professional ,
Apr 20, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 20, 2017 0
Explorer ,
Apr 20, 2017

Copy link to clipboard

Copied

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();

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 20, 2017 0
Adobe Community Professional ,
Apr 20, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 20, 2017 0
Explorer ,
Apr 20, 2017

Copy link to clipboard

Copied

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();

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 20, 2017 0
Adobe Community Professional ,
Apr 20, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 20, 2017 0