Problem with ContentChooser

Status
Not open for further replies.

XverhelstX

Well-Known Member
Licensed User
Longtime User
Hello,

I'm having trouble with the ContentChooser.
I don't know if it's a bug or something wrong with my code, but i'd like to grab a picture from my gallery or file manager.

B4X:
If Position = 1 Then
      Dim ivImage As ImageView
      Dim cc As ContentChooser
      ivImage.Initialize("ivImage")
      imgView = ivImage
      cc.Initialize("CC")
      cc.Show("image/*","Choose an image file.")
   End If

Sub CC_Result (Success As Boolean, Dir As String, FileName As String)
   Msgbox("called","called")
   If Success = True Then
      imgView.Bitmap = LoadBitmap(Dir, FileName)
      pnlEditor.AddView(imgView,pnlEditor.Width/2-50, pnlEditor.Height/2-50, 100, 100)
      vw = imgView
      Msgbox("This works!","Worked")
   Else
      Msgbox("Image failed to load.","Error")
   End If
End Sub

Now the problem is that sometimes the image loads (and msgbox shows) and sometimes it just doesn't and it goes back to the menu. (without a msgbox being called.)

It has been tested on Android 2.3, Android 3.0 and Android 4.0.

The (unfiltered) logs doesn't show a lot but it do call this every time.
onActivityResult: IOnActivityResult was released

Any input on this?

Tomas
 

cmweb

Active Member
Licensed User
Longtime User
Hello,

I have the same problem.

Sometimes the CC_Result sub won't be fired - and I don't know why.

My ContentChooser is dim'ed as Process Global.

Very obscure: When this happens, the EditText and ImageView views of the current activity are *empty*, even if they were filled before the ContentChooser started...

Any ideas?

Best regards,
Carsten
 
Upvote 0

cmweb

Active Member
Licensed User
Longtime User
Which steps reproduce it? Seems to work fine here.
It happens only *sometimes*. Push the button, select image -> CC_Result will be fired (then the MsgBox appears) or won't be fired (then the MsgBox won't appear).

It works in most cases, but not always. Ratio is approx. 1:25 (not working : working).

My device is a Galaxy Note with Android 4.0.4. Perhaps it is depending on the Android version or that specific device? Or a RAM problem?

Best regards,

Carsten
 
Upvote 0
Status
Not open for further replies.
Top