【问题标题】:Android Printing via Bluetooth SPP通过蓝牙 SPP 进行 Android 打印
【发布时间】:2012-06-13 22:18:22
【问题描述】:

我需要在我的 android 应用程序中打印纯文本。据我所知,我需要为我的设备创建一个带有 SPP UDID 的套接字。

我见过的示例代码,人们只是从 Socket 获取一个 OutputStream,然后将字符串与他们想要打印的文本一起推送。

就这么简单吗?只需通过 OutputStream 推送文本?

【问题讨论】:

    标签: android printing bluetooth


    【解决方案1】:

    试试这个打印文本:

        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();
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-24
      • 2017-12-14
      • 1970-01-01
      • 1970-01-01
      • 2011-12-28
      • 2013-03-10
      • 2014-07-22
      • 2017-08-07
      相关资源
      最近更新 更多