{BUG} Content Chooser does not work always?!

pleskina

Member
Licensed User
Longtime User
Hello,

I am not sure if this is a bug, and even if it is OS or B4A bug, but is quite annoying. Could very well be my lack of knowledge but I am trying to stay at B4A level without digging into Java-layer of Android programming.

I use ContentChooser as advised in many examples, to select a picture from "gallery". However, on several different devices I get unsuccessful.

- on one device (physical) it is not possible to choose as gallery does not close neither return image content
- on another device, I get "selection" between 2 apps to select a picture, but selection from neither works
- on third device, clicking any image does nothing
- on fourth device, selection sometimes works at once, sometimes as far as from 3rd try

Here is the code:
Sub btnLoad_Click
Dim ImageChooser As ContentChooser
ImageChooser.Initialize("imgChooser")
ImageChooser.Show("image/*", Common.Translate("Please select a picture"))
End Sub

Sub imgChooser_Result(Success As Boolean, Dir As String, FileName As String)
Dim s As String
If Success Then
ToastMessageShow(Common.Translate("Please wait..."), True)
Dim b As Bitmap
Dim out As OutputStream
b.InitializeSample(Dir, FileName, 300, 400)
out = File.OpenOutput(File.DirInternal, picname, False)
b.WriteToStream(out, 75, "JPEG")
out.Close
ImageView1.Bitmap = b
Else
ToastMessageShow(Common.Translate("There is a problem accessing file")&": "&Dir&"/"&FileName, False)
End If
End Sub

Quite simple, but does not always work.

Does anyone have *working* solution that will do on any device? Is there more "advanced" way to make sure picture gets selected via ContentChooser? Do we need to dive into API level?

Thanks in advance!

D.
 

pleskina

Member
Licensed User
Longtime User
This is the standard Android way to select an image. However it does depend on the installed applications to behave properly. On which device it doesn't work?

Hi Erel,

Thanks for quick reposnse. One device (not selecting at all) is Samsung Galaxy ACE.

On my Samsung Galaxy TAB 10.1, I get two applications offered to select between, when I choose gallery, it won't select and return an image.

On HTC WildFire, gallery opens, but picture comes back (Success is True) only after third click. Then, if I start chooser again, picture can be selected immediately.

Also, switching to fron camera on tablet does nothing.

Do I have right feeling that such things are hardly controllable? But I see many apps that work always, maybe there sre more things to be wrapped to B4A layer...

TIA,
Davor

Edit: On My ViewSonic 350V it works perfectly.
 
Top