Print via Bluetooth

0

Good I made an App with xamarin.Android and to print I found this code on the Internet but it does not print.

  var listOfDevices = BluetoothAdapter.DefaultAdapter.BondedDevices;

        foreach (BluetoothDevice bluetoothDevice in listOfDevices)
        {
            if (bluetoothDevice.Name != "BlueTooth Printer")
                continue;

            ParcelUuid uuid = bluetoothDevice.GetUuids().ElementAt(0);
            BluetoothSocket socket = bluetoothDevice.CreateInsecureRfcommSocketToServiceRecord(uuid.Uuid);
            socket.Connect();
            outStream = socket.OutputStream;

            //Printing

            byte[] toBytes = Encoding.ASCII.GetBytes("MY TEXT TO PRINT");
            outStream.Write(toBytes, 0, toBytes.Length);
            //socket.Close();
            //outStream.WriteByte(toBytes);
            //outStream.Close();

        }

If someone can help me thanks

    
asked by JOSE ANGEL RAMIREZ HERNANDEZ 19.04.2018 в 02:56
source

0 answers