Android Question Using contentchooser in B4Xtable don't work

yzhy-mail

Member
I want to insert a image to tabel in my project.
But, when I use contentchooser,the wait for has no return ,just in waitting...
I use Erel's example test this(Just for test the "CC"). It is still a problem.
I post the file
Maybe someone can help me !
Thank you !

which I changed:
Sub btnDuplicate_Click
'    Dim RowId As Long = GetRowId(Sender)
'    Dim Item As Map = B4XTable1.GetRow(RowId)
'    ShowDialog(Item, 0) 'RowId = 0 means that a new item will be created
'   
    Dim CC As ContentChooser 'Phone Library
    CC.Initialize("CC")
    Dim RowId As Long = GetRowId(Sender)
    Dim Item As Map = B4XTable1.GetRow(RowId)
    Dim picname As String  = Item.Get("Name")&".jpg"
    Log(picname)
    #if B4A
    CC.Show("image/*", "Choose image")
      
    Wait For(CC) CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success = True Then
        'File.Copy(Dir,FileName,xui.DefaultFolder,picname)
        xui.MsgboxAsync("ok","")
    End If
    #End If

End Sub
 

Attachments

  • B4XTableAndForms.zip
    14.6 KB · Views: 128

yzhy-mail

Member
Yes!
I have used this library in other app.
But this time ,I don't know where the issue is .
I searched it in the forums, and tested it with some other methods.
But cann't deal with it.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
ut this time ,I don't know where the issue is .
I used you code like this and was able to select an image using CC. I don't know why you would use CC here to insert an image in B4Xtable, which you cannot do is insert an image directly. With C, I was able to select an image, copy it to dirInternal using the name of the record previously imserted. The fact you are not getting CC to work has nothing to do with B4XTable. I hope Erel will enlighten us with a valid answer.
B4X:
Sub btnDuplicate_Click
'    Dim RowId As Long = GetRowId(Sender)
'    Dim Item As Map = B4XTable1.GetRow(RowId)
'    ShowDialog(Item, 0) 'RowId = 0 means that a new item will be created
'    
    Dim CC As ContentChooser 'Phone Library
    CC.Initialize("CC")
    Dim RowId As Long = GetRowId(Sender)
    Dim Item As Map = B4XTable1.GetRow(RowId)
    Dim picname As String  = Item.Get("Name")&".jpg"
    Log(picname)
    #if B4A
    CC.Show("image/*", "Choose image")
      
    Wait For(CC) CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success = True Then
        File.Copy(Dir,FileName,xui.DefaultFolder,picname)
        xui.MsgboxAsync("ok","")
    End If
    #End If
    Dim l As List
    l.Initialize
    l=File.ListFiles(xui.DefaultFolder)
    For Each s As String In l
        Log(s)
    Next
End Sub
 
Upvote 0

yzhy-mail

Member
Thank you Mahares !
Did you test the code in my first post project ? More than just testing this piece code.
In the post project ,click the "btnDuplicate",if you can see "OK",it works in your phone.
I want to make it sure.
 
Upvote 0

yzhy-mail

Member
Thank you so much Mahares !
It make me confused.
In my another project, the contentchooser works well.
I will check it in my HUAWEI phone again.
Thank you.
 
Upvote 0

yzhy-mail

Member
I don't konw if it was the reason that I debug step by step ,so the "wait for" is just in waitting.
No matter else, it works now.
 
Upvote 0
Solution
Top