4.14. ConnectionCallback

Notify the result when connecting / disconnecting

added in version 1.10.0

4.14.1. onConnected

added in version 1.10.0

Tells the connection result.

  • Declaration

    void onConnected(boolean result, int resultCode);
    
  • Parameter

    Name Contents Type
    result Connection result boolean
    resultCode Result code int
  • Return value

None

  • Error code

    Value Contents
    StarResultCode.FAILURE Some kind of error occurred.
    StarResultCode.FAILURE_IN_USE Connection was refused by the printer (another host is connected or other reason).
    StarResultCode.FAILURE_IN_PROCESS Connection process is already in progress.
  • Examples

    private final ConnectionCallback mConnectionCallback = new ConnectionCallback() {
        @Override
        public void onConnected(boolean result, int resultCode) {
            ...
    
            if (!result) {
            ...
    
            String message;
            if (resultCode == StarResultCode.FAILURE_IN_USE) {
                message = "Check the device. (In use)\nThen touch up the Refresh button.";
            }
            else {
                message = "Check the device. (Power and Bluetooth pairing)\nThen touch up the Refresh button.";
            }
    
            ...
    
            return;
            }
    
            ...
        }
    
        @Override
        public void onDisconnected() {
            // do nothing
        }
    };
    

    Refer to PrinterExtFragment.java, CashDrawerExtFragment.java, BarcodeReaderExtFragment.java and CombinationExtFragment.java.

4.14.2. onDisconnected

added in version 1.10.0

Tells the disconnect completed.

  • Declaration

    void onDisconnected();
    
  • Parameter

    None

  • Return value

    None

  • Examples

    Refer to the example of the onConnected method.