Hello I'm trying to do the wrapping for this library is a JAR
As I can access classes jar?
What am I doing wrong?
My code in Eclipse
My code en B4A
As I can access classes jar?
What am I doing wrong?
My code in Eclipse
B4X:
package lotenet.dpp250;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import com.datecs.api.printer.Printer;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
@DependsOn( values = { "datecs" } )
@Author( "Pablo Vidal" )
@ShortName("dpp250")
@Version((float) 0.50 )
public class dpp250 {
private Printer mPrinter;
/**
* Inicializa la Impresora
*/
public void printSelfTest(InputStream in, OutputStream out) throws IOException {
mPrinter = new Printer(in, out) ;
mPrinter.printSelfTest() ;
}
}
My code en B4A
B4X:
Sub Process_Globals
Dim PrintBuffer As String
Dim btAdmin As BluetoothAdmin
Dim cmp20 As Serial
'Dim printer As TextWriter
Dim oPrn As dpp250
End Sub
Sub Globals
Dim Toggla As Toggle
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
btAdmin.Initialize("BlueTooth")
cmp20.Initialize("Printer")
End If
'Toggla.TurnBluetoothOn
StartPrinter
End Sub
Sub Activity_Resume
'Toggla.TurnBluetoothOn
End Sub
Sub Activity_Pause (UserClosed As Boolean)
'Toggla.TurnBluetoothOff
End Sub
Sub Printer_Connected (Success As Boolean)
If Success Then
'printer.Initialize(cmp20.OutputStream)
'printer.WriteLine(PrintBuffer)
'printer.Flush
Msgbox("Start Printed!","")
oPrn.printSelfTest( cmp20.InputStream, cmp20.OutputStream )
Msgbox("Stop Printed!","")
'printer.Close
cmp20.Disconnect
Else
If Msgbox2("", "Printer Error","Reprint","Cancel","",Null) = DialogResponse.POSITIVE Then
StartPrinter
End If
End If
End Sub
Sub StartPrinter
Dim PairedDevices As Map
Dim L As List
Dim Res As Int
ToastMessageShow("Printing.....",True)
PairedDevices.Initialize
Try
PairedDevices = cmp20.GetPairedDevices
Catch
Msgbox("Getting Paired Devices","Printer Error")
'printer.Close
cmp20.Disconnect
End Try
If PairedDevices.Size = 0 Then
Msgbox("Error Connecting to Printer - Printer Not Found","")
Return
End If
If PairedDevices.Size = 1 Then
Try
cmp20.ConnectInsecure(btAdmin,PairedDevices.Get(PairedDevices.GetKeyAt(0)),1)
Catch
Msgbox("Connecting","Printer Error")
'printer.Close
cmp20.Disconnect
End Try
Else
L.Initialize
For i = 0 To PairedDevices.Size - 1
L.Add(PairedDevices.GetKeyAt(i))
Next
Res = InputList(L, "Choose device", -1)
If Res <> DialogResponse.CANCEL Then
cmp20.Connect(PairedDevices.Get(L.Get(Res)))
End If
End If
End Sub
Last edited: