List Documents folder with android 11

My blocks runs well with Companion, but not with installed apk.

1 Like

EDIT: please see the overview

Using the file component you only can get a list of media files, for other files you have to use SAF...

Taifun
PS: I agree.. companion app and apk file should provide the same result... @ewpatton

4 Likes

But what if he has already granted MANAGE_EXTERNAL_STORAGE ? :thinking:

2 Likes

To be more precise:
Using the File component or one of the File extensions (from Taifun or Sunny) you only can get a list of media files and non-media files that were created by the app itself. For non-media files that are not created by the app, you have to use SAF.

I think Companion provides the same results, but it lists all non-media file that were created by the Companion app. So to get the same results with Companion as with the app (APK), you should delete the AppInventor folder (from the ASD) beforehand (before testing with Companion).

5 Likes

I think in order to be able to request and grant this permission, additional entries are required in the Manifest. It is not enough to just ask for MANAGE_EXTERNAL_STORAGE.
So I'm pretty sure he didn't grant this permission.

2 Likes

I'm asking for listing a shared folder, why I need special permission ?

1 Like

As I said earlier, the app only has access to media files and non-media files created by the app itself. To get access to non-media files that were not created by the app, either SAF or MANAGE_EXTERNAL_STORAGE (which grants unrestricted access to all files of the device) is required.

1 Like

My manifest (sdk = 30)

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<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"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<application android:debuggable="false" android:icon="@mipmap/ic_launcher" android:label="DOC30" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication" android:networkSecurityConfig="@xml/network_security_config" android:preserveLegacyExternalStorage="true" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:theme="@style/AppTheme">
    <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:name=".Screen1" android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <provider android:authorities="appinventor.ai_andrea_patelli.DOCUMENTI_301.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
    </provider>
</application>

something wrong ?

1 Like

you modified the manifest and added "MANAGE_EXTERNAL_STORAGE" manually.. .
which results in your app not being accepted by Google Play anymore...
you should mention that next time in your first post...

did you use the AskForPermission method together with MANAGE_EXTERNAL_STORAGE?
also you might want to try one of the file extensions to get a list of the files of that directory...

Taifun

2 Likes

I'm sorry, but I don't understand, I showed my blocks.

1 Like

use the AskForPermission method from the Screen drawer together with the permission MANAGE_EXTERNAL_STORAGE during Screen Initialize

this should be used only by experienced users who know, what they are doing...

Taifun

2 Likes

I tried but permission denied

1 Like

@Anke showed an example in the Kodular community how to do it...


Taifun

3 Likes

Try this app on your Android 11+ (test) devices:

I didn't have to manually add this line to the Manifest as I created a small extension that automatically declared it there.

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
1 Like

See also here (same app on Niotron):

1 Like

I tried without success, your app is not present in the app list and doesn't save text file

1 Like

What does that mean?

1 Like

I'm sorry, it is in the list, but with the note access denied to all files

1 Like

Did you do this:

1 Like

I did not last time, but I did now, your app runs well, file saved.
I am waiting to know how to do it

2 Likes