Class br.com.softwareexpress.sitef.android.CliSiTef

In this model, transactions use the concept of listener/events/call-back. In other words, commercial automation registers a function that will be called during the transaction flow.

As it is an exclusive implementation for Android environments, the integration of automation in this environment is much simpler when compared to interfaces on other platforms.

To couple the class to your application, simply call the constructor, passing the application context as a parameter.

To receive additional events (such as PinPad connection status changes), assign an appropriate android.os.Handler.

clisitef = new CliSiTef (this.getApplicationContext ());
clisitef.setMessageHandler (hndMessage);

Important: only instantiate CliSiTef once, to avoid competition problems with the pinpad.

Before starting a transaction, the automation must implement the ICliSiTefListener interface:

public interface ICliSiTefListener extends EventListener {
public void onData (int currentStage, int command, int fieldId, int minLength,
int maxLength, byte [] input);
public void onTransactionResult (int currentStage, int resultCode);
}

The transaction is initiated from the startTransaction method, which receives as an initial parameter an object that implements ICliSiTefListener, and the other parameters analogous to those of iniciaFuncaoSiTefInterativo.

// Assuming ‘this’ implements ICliSiTefListener
int sts = clisitef.startTransaction (this, modality, value, docFiscal,
taxDate, taxTime, operator, restrictions);

This method returns immediately. If it returns zero, the onData and onTransactionResult events will be fired.

For each onData event, the application receives the data necessary for collection. After this event, you can choose to continue the transaction (continueTransaction method – passing the collected data), or cancel the flow (through the abortTransaction method).

The onTransactionResult event indicates the end of the transaction, returning the transaction return code. A value of zero indicates transaction success.

In this case, the automation must confirm/unconfirm the transaction, using the finishTransaction method.

Analogously to the startTransaction method, this method returns immediately and, from then on, the collection events will be received in onData and onTransactionResult.