Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

java.io.IOException: Software caused connection abort while print data in Bluetooth printer

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am trying to create a demo app in Android which will basically do the following:

  • Search for bluetooth device. The devices will be displayed in a ListView.
  • On clicking any device, it will attempt to make a connection to the Bluetooth device.
  • After connection to a device is successful, a TextBox will be displayed with a Print button.
  • On clicking the Print button, the contents of the texts will be sent to a Bluetooth printer for printing.


  • I am able to make connection with the Bluetooth printer successfully. However on press on the "Print" button I am getting the exception:


    Following are the related code for Bluetooth connection and Printing.

    AndroidBluetoothUtils.java(A utility class for all BT related activities)


    BluetoothAdapter.java(A custom BaseAdapter created for a ListView which will display the Bluetooth device on search and on click of list item will attempt to connect to the device)



    I am calling the AndroidBluetoothUtils.printData(printNoteMessage.getBytes()) from another Activity on the onClick event of the "Print" button.



    Is there something I am doing wrong in this approach ? I have been trying to google this problem without finding the cause for this exception. Please help as I have been stuck with this issue for over a week now.
     
    WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    reply
      Bookmark Topic Watch Topic
    • New Topic