Home » Android » printing – Android send file/data from application through Bluetooth to the PC/printer/scanner/another device

printing – Android send file/data from application through Bluetooth to the PC/printer/scanner/another device

Posted by: admin June 15, 2020 Leave a comment

Questions:

Can anyone help me/ suggest me how can I fulfill this requirements? I searched on the same topic but I can not understand from where OR how can I get the Bluetooth devices which are currently enabled.

EDIT:-

Now, I am able to searching other devices and pairing with devices but still I am not able to transfer the file via bluetooth.

I refereed this and this.

I think other operations will starting after that.

How to&Answers:

you can use http://www.java2s.com/Open-Source/Android_Free_Code/Bluetooth/Download_Free_code_Bluetooth_Chat.htm (bluetooth chat example) for the communication between devices. In bluetooth chat example there is BluetoothChatService java class which deals with making the bluetooth connection, establishing the socket and then transfer the data. All these function are performed in different thread in thread safe manner. You can use this file in your app and make an instance of the class and call the write function to write the data. And data received will be handled by the handler variable of the activity (by the mHandle.obtainMessage()).

In case if you want to communicate with a particular device like printer or pc then you have to find out communication protocol they accept and then form a class for converting your data to the desired protocol for the external device.