Sub Button1_Click
Dim InboxUri As Uri
InboxUri.Parse("content://mms/inbox")
Dim cursor1 As Cursor = cr.Query(InboxUri, Null, "", Null, "")
Dim mmsId As Int = 0
For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
'// To get the id of the very last MMS in the database, or any MMS just to test
If i = 0 Then
mmsId = cursor1.GetString("_id")
End If
Next
Log("The MMS Id is = " & mmsId)
cursor1.Close
InboxUri.Parse("content://mms/part")
Dim cursor2 As Cursor = cr.Query(InboxUri, Null, "mid = ?", Array As String(mmsId), "")
Dim data() As Byte
For i = 0 To cursor2.RowCount - 1
cursor2.Position = i
If cursor2.GetString("ct").Contains("image") Then
'datapath = cursor2.GetString("_data")
data = cursor2.GetBlob("_data")
End If
Next
cursor2.Close
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(data, 0, data.Length)
'Read stream into image view
Dim Bitmap1 As Bitmap
Bitmap1.Initialize2(InputStream1) '// <-- ERROR IS HERE (WITH DEBUG MODE)
InputStream1.Close
ImageView1.Bitmap = Bitmap1
End Sub