Android App to print from a bluetooth printer

独自空忆成欢 提交于 2019-12-06 07:39:32

I added code to run closeBT function at the end of the sendData function. if you don't close the connection, I think it is hanging in the process of sending.

void sendData() throws IOException {
try {

    // the text typed by the user
    String msg = myTextbox.getText().toString();
    msg += "\n";

    mmOutputStream.write(msg.getBytes());

    // tell the user data were sent
    myLabel.setText("Data Sent");

}   catch (NullPointerException e) {
    e.printStackTrace();
     } catch (Exception e) {
    e.printStackTrace();
   }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!