Android Question [Solved] translate to B4A please

Discussion in 'Android Questions' started by noeleon, Dec 5, 2019 at 12:38 AM.

  1. noeleon

    noeleon Member Licensed User

    I want the system filepicker to start in a previously saved folder. Upon searching the web I found this, which requires api26+

    intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, your_initial_uri);

    I've already tried a lot of variations for the first parameter bu still no luck. Help please.
  2. stevel05

    stevel05 Expert Licensed User

    noeleon likes this.
  3. noeleon

    noeleon Member Licensed User

    Hi @stevel05!

    Still not working. There is no error and no prompt for any permission.

    Maybe my second parameter is wrong? I got that from the log running the code below. I'm using Android 10

    Sub Process_Globals
    Private ion As Object
    End Sub

    Sub Globals
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    End Sub

    Sub Activity_Click
    Dim i As Intent
    End Sub

    Sub ion_Event (MethodName As String, Args() As Object) As Object
    If Args(0) = -1 Then 'resultCode = RESULT_OK
            Dim i As Intent = Args(1)
    Dim jo As JavaObject = i
    'Android 4.1+ (API 16)
            Dim uris As List
    Dim clipdata As JavaObject = jo.RunMethod("getClipData"Null)
    If clipdata.IsInitialized Then
    Dim count As Int = clipdata.RunMethod("getItemCount"Null)
    For i2 = 0 To count -1
    Dim item As JavaObject = clipdata.RunMethod("getItemAt"Array(i2))
    End If
    End If
    Return Null
    End Sub

    Sub StartActivityForResult(i As Intent)
    Dim jo As JavaObject = GetBA
        ion = jo.CreateEvent(
    "startActivityForResult"Array As Object(ion, i))
    End Sub

    Sub GetBA As Object
    Dim jo As JavaObject
    Dim cls As String = Me
        cls = cls.SubString(
    "class ".Length)
    Return jo.GetField("processBA")
    End Sub
  4. noeleon

    noeleon Member Licensed User

    doesn't work on tree uri too
  5. DonManfred

    DonManfred Expert Licensed User

    I guess you need to use FileProvider

    What exactly are you trying to implement?
  6. stevel05

    stevel05 Expert Licensed User

    I have not used this, and am not sure how permissions play a part (if at all) with this process but accessing external drives always appears problematic. Does it work if you set the parameter to point at an internal file path?
  7. noeleon

    noeleon Member Licensed User

    finally solved it. Thank you @stevel05, @DonManfred
    Dim Uri As Uri
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice