Private Sub Camera1_Preview (CData() As Byte)
If DateTime.Now > LastPreview + IntervalBetweenPreviewsMs Then
'Dim n As Long = DateTime.Now
Dim frameBuilder As JavaObject
Dim bb As JavaObject
bb = bb.InitializeStatic("java.nio.ByteBuffer").RunMethod("wrap", Array(CData))
frameBuilder.InitializeNewInstance("com/google/android/gms/vision/Frame.Builder".Replace("/", "."), Null)
Dim cs As CameraSize = camEx.GetPreviewSize
frameBuilder.RunMethod("setImageData", Array(bb, cs.Width, cs.Height, 842094169))
' frameBuilder.RunMethod("setImageData", Array(bb, 400, 300, 842094169))
Dim frame As JavaObject = frameBuilder.RunMethod("build", Null)
Dim SparseArray As JavaObject = detector.RunMethod("detect", Array(frame))
LastPreview = DateTime.Now
Dim Matches As Int = SparseArray.RunMethod("size", Null)
If Matches > 0 Then
Dim barcode As JavaObject = SparseArray.RunMethod("valueAt", Array(0))
Dim raw As String = barcode.GetField("rawValue")
Dim numstr As String = raw.SubString2(1,11).As(Int).As(String)
If edit_papnr.Text <> numstr Then
edit_papnr.Text=numstr
Dim b As Beeper
b.Initialize(100,1600)
b.Beep
End If
' FoundBarcode(raw)
End If
End If
End Sub