I'm trying to share an image extracted from the database, but I keep getting this error : java.lang.RuntimeException: java.lang.IllegalArgumentException: method java.io.File.<init> argument 1 has type java.lang.String, got android.graphics.Bitmap
I'm using this procedure to recover the image from the db. The variable (ShareBitmap) inherits the image from the db.
through the Share button (Share) I create the event, with the Variable (ShareBitmap) that contains the image.
I'm using this procedure to recover the image from the db. The variable (ShareBitmap) inherits the image from the db.
B4X:
Sub ListViewImage_ItemLongClick (Position As Int, Value As Object)
PanelOpzioniPass.Visible=True
Dim Cursor1 As Cursor
Dim Name As String
Dim Buffer() As Byte
Dim IpSt As InputStream
Dim Bitmap1 As Bitmap
Cursor1 = s.ExecQuery("SELECT Picture FROM Image")
For i = 0 To ListViewImage.Size-1
Cursor1.Position = Position
Next
Buffer = Cursor1.GetBlob("Picture")
IpSt.InitializeFromBytesArray(Buffer,0, Buffer.Length)
IpSt.Close
Bitmap1.Initialize2(IpSt)
ShareBitmap = Bitmap1
Cursor1.Close
End Sub
through the Share button (Share) I create the event, with the Variable (ShareBitmap) that contains the image.
B4X:
Sub BtCondividi_Click
Dim r As Reflector
Dim f As Object
f = r.CreateObject2("java.io.File", Array As Object(ShareBitmap), Array As String("java.lang.String"))
Dim share As Intent
share.Initialize(share.ACTION_SEND,"")
share.SetType("image/*")
share.PutExtra("android.intent.extra.STREAM", r.RunStaticMethod("android.net.Uri", "fromFile", _
Array As Object(f), Array As String("java.io.File")))
share.WrapAsIntentChooser("Share With")
StartActivity(share)
End Sub