Java Question Handlers in Java libraries

TheMightySwe

Active Member
Licensed User
Longtime User
This is the original handler code from a LAN Printer SDK, how do you initialize it to work with a B4A Application.

B4X:
    private final Handler sHandler = new Handler(new Handler.Callback()
    {
       
        public boolean handleMessage(Message msg)
        {
            switch (msg.what)
            {
                case MetapacePrinter.MESSAGE_NETWORK_DEVICE_SET:

                if (msg.obj != null) {
                    Set<String> ipAddressSet = (Set<String>) msg.obj;
                    for (String ipAddress : ipAddressSet)
                    {
                        if (ipAddress.equals("192.168.0.100"))
                        {
                            // TODO: Connect printer
                            break;
                        }
                    }
                }
                break;
            }
            return true;
        }

    });
 
Top