4 Replies Latest reply on Mar 24, 2017 3:43 AM by muhammad ali

    BluetoothDiscoverer.findPrinters() does go to call back.

    muhammad ali

      I am trying following code to find bluetooth printers. The code runs fine on API 4 however it does not run on API 6. It starts looking for the bluetooth printers but did not go to any callbacks or neither throw any error.  I am using ZSDK_API 2.9.2275.jar. Please let me know what I am doing wrong. Thanks in advance. 

       

      private void lookForPrinters() {

        @Override

         public void run() {

         try {

        BluetoothDiscoverer.findPrinters(MainActivity.this, new DiscoveryHandler() {

        @Override

         public void foundPrinter(DiscoveredPrinter discoveredPrinter) {

        DiscoveredPrinterBluetooth discoveredPrinterBluetooth = (DiscoveredPrinterBluetooth) discoveredPrinter;

         if  (discoveredPrinterBluetooth.friendlyName != null && discoveredPrinterBluetooth.friendlyName.startsWith("XXXX")) {
         Log.i(TAG, "Discovered a printer"  + discoveredPrinterBluetooth.friendlyName);

        }

        }

      @Override

         public void discoveryFinished() {

        Log.i(TAG, "Discovery finished");

        }

      @Override

         public void discoveryError(String s) {

        Log.i(TAG, "Discovery error");

        }

        });

        }

         catch (ConnectionException e) {

        Log.i(TAG , e.getMessage());

        }

       

        }

        });

        }