Permissions help

Dear Sinieer, Thank you very much for thinking about me I am glad to know that you have solved your problem.
I have checked the link you posted and I have seen there are changes since 30 of july 2020.

This is what I have added to my code.


This is the behaviour of the app after the code:
When I start downloading it says: "Do you want to install this application. It does not require special permissions". however If you see the code I apply for the permissions READ and WRITE

After app is installed it says the following:
"Application needs your permission to access to photos and multimedia files"

Either I Accept or deny gives me the error
It says:
Error 908 The permission "READ_EXTERNAL_STORAGE has been denied.

When I check permissions for the app on my mobile
It has permission but only to read but not to write

It works normallytest (1).aia (2.1 KB)

Guys

Instead of requesting READ_EXTERNAL_STORAGE when Screen1 Initialize,
request WRITE_EXTERNAL_STORAGE only

Once granted write permission, read permission should be automatic.

@ Javier you have a typo in the 2nd IF of the when Screen1 Permission Granted Block:

you have WRITE_EXTERNALSTORAGE
should be WRITE_EXTERNAL_STORAGE

You only need to test permissionName for WRITE_EXTERNAL_STORAGE

1 Like

Thank you very very much Chris, that typo was in front of me and I did not notice, Thank you again!!

Yes, to ask for permissions (and grant / deny them), they must be declared in the Manifest.

There is no permission for that. You need to use the KeepScreenOn method of the TaifunTools extension App Inventor Extensions: Tools | Pura Vida Apps

grafik

And as @ChrisWard said, WRITE_EXTERNAL_STORAGE is sufficient as it implicitly grants READ permission. Manifest.permission  |  Android Developers

1 Like

For BLE see here:

Dear Anke, Thank you very much for all your help, you are really a kind person. Danke Schön.
I have one last question how to manage permission Deny.
when I press Deny it works ok the first time to print "please we need your permission tu run this app", but next time when I press deny error 908 appears.
Have a nice evening.

Thanks a lot for your message TIMAI2

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Thank you for the suggestion Taifun!!

Hi Taifun,

I think there is something wrong with the new AI2 version. I always test my project by installing it on my phone after it is removed for debugging. To day I found that whether or not I ask for permission (WRITE_EXTERNAL_STORAGE) in my application, I was prompted to answer for permission by the system. When I answer "Yes", it doesn't go to my "PermissionGranted" procedure and just hang there with a black screen. If I answer "No", it will go to my "PermissionDenied" procedure and then I will ask for permission again, and everything works fine from there. But it is not logical to answer "No" in the beginning, and I am sure the first permission is not asked by my app ("screen1.AskForPermission").

Truely,
Anthony Chow

usually you will be asked by the system, if a permission is required but still not granted

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.
Also which device and Android version are you using for your tests?

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

if you really like to get help, then providing a screenshot of your relevant blocks would make more sense...
Taifun

Hi Taifun,

I just created a testing project and found that the problem was a little bit different. In my previous project, the screen was hanged because my app only let user pass through the "PermissionGranted" procedure, otherwise my app would be waiting for loading files. In the testing project, I found that whenever I asked for Permission ("screen1.AskForPermission"), no matter I input "Yes" or "No", it will go to the "PermissionDenied" procedure, and the "Permission granted" message was never shown.

I tested with the "nb183c" offline version, the problem was still there. But when I imported the test project to Kodular, I get the permission granted and everything is fine. Below is my test project "Test.aia".

Test.aia (2.5 KB)

By the way, all the testings were failed on phones installed with android 7, 9 & 10.

Thanks in advance.

Truely,
Anthony Chow

Of course, this aia won't work at all.
The permission (WRITE_EXTERNAL_STORAGE) cannot be requested / granted because it is not declared in the Manifest. So add the File component and try again.

EDIT: I checked this: Yes, you are correct.
I will examine which component declares the permission in the Manifest.

See here:

WebViewer permissions

Note: AI2 does not add READ / WRITE permissions to the Manifest for the WebViewer component.

In order to request a permission, it must be declared in the Manifest.

Therefore, if you want to request WRITE permission, there are two options:

  1. Customize the Manifest and add this line:
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

  2. Insert a component (as a dummy) that requires this permission (e.g. the File component).

Hi Anke,

Thanks for the reply. Now I know I had created a very bad example for showing my case. Anyway, the logic for asking permission in my original project is similar to the testing app and I do have a few file components in my app.

I had tested my project under the "nb183c" offline version and kodular. Both cases work OK as before (I haven't changed my permission coding for quite a long time).

But under the current version of AI2, it never goes to "PermissionGranted" when I type "Yes", and just stop there waiting for file loading, and my app won't continue until I received the required content. Unless I input "No" to force it to go to "PermissionDenied", I can't go through the permission procedure.

Truely,
Anthony Chow

No, I checked it again (nb183c, offline version). WRITE permission is not declared in the Manifest.

With your Test.aia only these permissions are declared:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

Hi Anke,

So, what is your suggestion that I should do in the coding in my original project so that I can go through the permission process ?

Anthony