Android Question PERMISSION_WRITE_EXTERNAL_STORAGE in B4XPages not showed (SOLVED)

netsistemas

Active Member
Licensed User
Longtime User
I search in forum but i can't find a solution.

(
note: 6 hours more late:
Solution. First this code
B4X:
Dim FilePath As String

    If File.ExternalWritable Then FilePath = Rp.GetSafeDirDefaultExternal("") Else FilePath = File.DirInternal
)

how get permision por write_external_store.

Attach demo with this simple code in b4xpainpage:

B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")

  
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click

  
    Dim rp As RuntimePermissions
      
      
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
  
    xui.MsgboxAsync("Hello world!", Permission)
End Sub

and this in manifest:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.


AddManifestText(<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="19" />
)

AddManifestText(<uses-permission android:name="android.permission.CAMERA" />)

SetApplicationAttribute(android:requestLegacyExternalStorage, true)
 

Attachments

  • BORRABLE.zip
    10 KB · Views: 156
Last edited:

netsistemas

Active Member
Licensed User
Longtime User
sorry and thanks, but.

The problem is that
- No Permision are showed for user.

if you put this code:
B4X:
rp.CheckAndRequest(rp.PERMISSION_CAMERA  )

'instead

rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)

A message are showed to user.

why no External Storage Permision?
 
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
with this code ?
B4X:
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)

you recive a permision?
you use B4X VERSION 10.9?
 
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
and you are used my demo-proyect? (with no b4xpages i think are ok, and run, but in b4xPage no work)
 
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
Thanks, agraham... finally i search and search and i found the solution.

Its amazing!!!

the app need BEFORE, know thak you go to acces to files. If you don't do this, the app don't show the solicitud of permmision.

that is:
include a simple code BEFORE:

B4X:
Dim FilePath As String
    If File.ExternalWritable Then FilePath = Rp.GetSafeDirDefaultExternal("") Else FilePath = File.DirInternal

and solved.
then, the message are showed by android
B4X:
tarter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)


in all my proyect, before i do this after always (and i have not this problema never): ... file.dirinternal, but in this new proyect i use barcode detect and the code, never execute this instrucction.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…