简体   繁体   中英

Android Printing via Bluetooth SPP

I need to print plain text in my android application. As far as I can tell I need to create an socket with SPP UDID to my device.

The sample codes I've seen, people just get an OutputStream from the Socket and the push the string with the text they want to print.

Is is that simple? Just push text through OutputStream?

Try this for print text:

    try {
             Socket clientSocket = null;
             DataOutputStream outToServer;

             try {
                clientSocket = new Socket("192.168.101.64", 9100);
            } catch (UnknownHostException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

             outToServer = new DataOutputStream(clientSocket.getOutputStream());

             outToServer.writeUTF("Some string to print");
            }

             outToServer.close();
             clientSocket.close();
             } catch (IOException e) {
                e.printStackTrace();
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM