2
I have the following code for printing in P.O.S on Android; Before calling pass the data to thermal printing, I make the call to test if the printer has paper or is all right with it.
PrinterDemo.getInstance(getApplicationContext(),toast,dialog).testeImpressao();
The content of the testing method is as follows :
public void testeImpressao() throws RemoteException {
Printer.getInstance().getStatus();
Printer.getInstance().start(new OnPrintListener.Stub() {
@Override
public void onFinish() throws RemoteException {
Log.d(TAG, "----- onFinish -----");
SendJsonPayment.eita = "deucerto";
//hideDialog();
//showToast(R.string.succeed);
}
@Override
public void onError(int error) throws RemoteException {
Log.d(TAG, "----- onError ----");
SendJsonPayment.eita = "deuerrado";
//hideDialog();
//showToast(Printer.getErrorId(error));
}
});
}
The problem is that I need to know if everything is all right before sending the printout data but right after that line "Printer.getInstance().start(new OnPrintListener.Stub()"
it leaves the block and goes back to the subsequent line of the test method call which is where I perform the test whether it worked or not :
if (eita.equals("deucerto"))
And then you come back and fall into the method onError
that is my condition is never satisfied , I would like to know how I make it to execute soon and present me the error before the test happens.