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.
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.