Hello everybody. I wish to report a possible bug regarding permissions on latest Android 10 ( Samsung Galaxy S10e ), tested using AppGameKit Classic.
I have noticed that if we asked for permission to 'Write External' using
RequestPermission( "WriteExternal" ) , the permission seems to be granted, but any attempt to write files to 'document' path will be rejected, as if the app wasn't granted permission yet.
Even if we checked the permission first using CheckPermission( "WriteExternal" ) = 2 , and confirmed the permission to be granted, the write will still fail and crash the program, returning an errror:
"Error: Failed to create folder "emulated" in path "/storage/emulated/0/testsavedata/testarray.json", the app may not have permission to create in main.agc at line 36 "
As you can see, it's almost as if the app is trying to create a folder named "emulated' inside the final file name (testarray.json), and fail.
However, this bug does not seems to occur in older Android versions. The external file and folders was successfully created in older Android version.
Please test the bug on Android 10, to see if it occurs in other Android smartphone running the same Android version. I have only tested it on one smartphone with Android 10.
Thank you for your attention. I hope this can be fixed.
Example project file included:
// Project: TEST Permission BUG
// Created: 2020-07-25
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "TEST Permission BUG" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
// Ask write permission
IF CheckPermission( "WriteExternal" ) = 0
RequestPermission( "WriteExternal" )
WHILE CheckPermission( "WriteExternal" ) <> 2
ENDWHILE
ENDIF
GLOBAL saveDataPath$
saveDataPath$ = "raw:" + GetDocumentsPath() + "/testsavedata/"
GLOBAL testarray AS INTEGER[]
testArray.insert(1)
IF CheckPermission( "WriteExternal" ) = 2
testarray.save( saveDataPath$ + "testarray.json" )
ENDIF
do
Print( "Save successful" )
Print( ScreenFPS() )
Sync()
loop