This content details the process of creating an Android application that enables printing to a Bluetooth thermal printer, covering project setup, UI design, Bluetooth connectivity, and the printing logic for invoices.
Mind Map
Click to expand
Click to explore the full interactive mind map • Zoom, pan, and navigate
in this video I am creating an Android project
printing in Bluetooth thermal printer
let's start
and select
empty views activity
now insert the project name Bluetooth
thermal printer
and select language coding
and now go to Resource folder
and layout
and insert a
and I edit text
and name this device name
and a button
and
print
and now they select the button select printer
printer
and create a function on click function
over the mouse here and create
scan BT on activity Main
and now create a function under
print button
ID button to function
function Underground
Underground
create a function print
first go to the folder option
Gradle
click on build Gradle and
view binding build feature view binding
equal true
declare a variable binding activity main binding
binding
and inflate the layout inflator
and set the title bluetooth printer
example in kotlin
and set here the user's permission for Bluetooth
I have set some permission
Android dot Bluetooth permission dot Bluetooth
Bluetooth
4 as SDK label 30 maximum level 13. and
Bluetooth admin
and Bluetooth permission
Bluetooth connect Bluetooth advertise
and now go to layout folder
and create new
XML
now I have created
2xml layout file
item underscore list.xml
for displaying
paired device list
and another it
go to the code
and scan BT Dot XML
and now so the code view for
and atom this BT LST
and set ID
first create a class
right click here new
new
kotlin class
and name this
connection class
and declare some function here some
I have declared some variables BT permission
permission
and set the value false
for storing the current status for
Bluetooth connection Bluetooth permissions
permissions and
and
Bluetooth adapter
sockets Bluetooth devices output steam
input stream
and work thread read buffers
and read buffer position
and now declare some more
were stock worker set the value false
private war value set the value empathy
empathy
and now initialize the connection class here
first create a Bluetooth launcher
because it can be BT is already
first declare this annotation missing permission
permission
and declare
variables Bluetooth manager Bluetooth adapter
adapter
and create a alert dialog box
for displaying paired device
and this is the code
and now go to the this part
and insert the code
now create a function pour in slice printer
and insert The annotation for missing
and insert the code under this function
print invoice
I am making a small
these variables
invoice header text in Wise address the contact
contact
in this string Builder store
store
header data
and middle data in this data one store
middle data
for storing invoice
and now text Data dot append these
company name
Bill numbers
Now set the printer align left
and append data on
text Data one
in this section store in Wise detail
and set the price 10 items and value of I
now append the data on Text data 2.
in this section
we will store totals value
in this section
I will set the printer's font size double
so total value is displaying a big size
of font
in the large section is the footer section
section
in this last section
and four empty lines
in the last section we will set the font size
normals
and now create a function
now create a function
create a function for printing
and now check the condition if
connection class dot printer name
first initialize the printer
printer
and these are the codes
and this is
and align left
these byte codes for Align left
and font size
and finally flush the output stream
and close the socket and close the
this is the code
and pass here all
and these are string Builder to convert
to string
and insert a code under
check permission
if permission granted then print invoice
now run the application
error in displaying
while debugging
manifest file
multiple errors
Now app is running perfectly
and tested in this app in physical device
Click on any text or timestamp to jump to that moment in the video
Share:
Most transcripts ready in under 5 seconds
One-Click Copy125+ LanguagesSearch ContentJump to Timestamps
Paste YouTube URL
Enter any YouTube video link to get the full transcript
Transcript Extraction Form
Most transcripts ready in under 5 seconds
Get Our Chrome Extension
Get transcripts instantly without leaving YouTube. Install our Chrome extension for one-click access to any video's transcript directly on the watch page.