0:29 in this video I am creating an Android project
0:36 printing in Bluetooth thermal printer
0:38 let's start
0:48 and select
0:52 empty views activity
1:04 now insert the project name Bluetooth
1:07 thermal printer
1:09 and select language coding
1:31 and now go to Resource folder
1:32 and layout
1:57 and insert a
2:04 and I edit text
2:08 and name this device name
2:10 and a button
2:19 and
2:25 print
2:35 and now they select the button select printer
2:36 printer
2:40 and create a function on click function
2:50 over the mouse here and create
2:54 scan BT on activity Main
2:58 and now create a function under
3:00 print button
3:03 ID button to function
3:06 function Underground
3:08 Underground
3:11 create a function print
3:32 first go to the folder option
3:38 Gradle
3:41 click on build Gradle and
3:54 view binding build feature view binding
3:56 equal true
4:38 declare a variable binding activity main binding
4:40 binding
4:42 and inflate the layout inflator
4:45 and set the title bluetooth printer
4:48 example in kotlin
4:57 and set here the user's permission for Bluetooth
5:10 I have set some permission
5:12 Android dot Bluetooth permission dot Bluetooth
5:14 Bluetooth
5:19 4 as SDK label 30 maximum level 13. and
5:21 Bluetooth admin
5:23 and Bluetooth permission
5:27 Bluetooth connect Bluetooth advertise
5:36 and now go to layout folder
5:38 and create new
5:43 XML
5:49 now I have created
5:52 2xml layout file
5:54 item underscore list.xml
5:56 for displaying
5:58 paired device list
6:01 and another it
6:09 go to the code
6:20 and scan BT Dot XML
6:28 and now so the code view for
6:45 and atom this BT LST
6:53 and set ID
7:32 first create a class
7:34 right click here new
7:35 new
7:38 kotlin class
7:40 and name this
7:42 connection class
8:40 and declare some function here some
8:46 I have declared some variables BT permission
8:47 permission
8:51 and set the value false
8:55 for storing the current status for
8:57 Bluetooth connection Bluetooth permissions
8:58 permissions and
9:00 and
9:03 Bluetooth adapter
9:07 sockets Bluetooth devices output steam
9:08 input stream
9:12 and work thread read buffers
9:15 and read buffer position
9:18 and now declare some more
9:27 were stock worker set the value false
9:31 private war value set the value empathy
9:32 empathy
9:38 and now initialize the connection class here
9:43 first create a Bluetooth launcher
15:38 because it can be BT is already
15:44 first declare this annotation missing permission
15:45 permission
15:52 and declare
15:54 variables Bluetooth manager Bluetooth adapter
15:55 adapter
15:58 and create a alert dialog box
16:02 for displaying paired device
16:22 and this is the code
16:39 and now go to the this part
17:48 and insert the code
18:12 now create a function pour in slice printer
19:42 and insert The annotation for missing
19:51 and insert the code under this function
20:31 print invoice
21:19 I am making a small
21:30 these variables
21:34 invoice header text in Wise address the contact
21:36 contact
22:50 in this string Builder store
22:52 store
22:54 header data
22:57 and middle data in this data one store
22:59 middle data
23:06 for storing invoice
23:13 and now text Data dot append these
23:19 company name
23:32 Bill numbers
23:45 Now set the printer align left
23:48 and append data on
23:50 text Data one
24:10 in this section store in Wise detail
24:20 and set the price 10 items and value of I
24:35 now append the data on Text data 2.
24:38 in this section
24:41 we will store totals value
24:48 in this section
24:52 I will set the printer's font size double
24:58 so total value is displaying a big size
25:00 of font
25:02 in the large section is the footer section
25:04 section
25:06 in this last section
25:17 and four empty lines
25:24 in the last section we will set the font size
25:28 normals
25:36 and now create a function
25:49 now create a function
26:03 create a function for printing
27:26 and now check the condition if
27:28 connection class dot printer name
27:36 first initialize the printer
27:38 printer
28:01 and these are the codes
28:11 and this is
28:18 and align left
28:21 these byte codes for Align left
28:24 and font size
28:45 and finally flush the output stream
28:47 and close the socket and close the
28:53 this is the code
29:50 and pass here all
30:35 and these are string Builder to convert
30:37 to string
31:19 and insert a code under
31:50 check permission
31:52 if permission granted then print invoice
31:59 now run the application
32:10 error in displaying
32:12 while debugging
32:14 manifest file
32:16 multiple errors
32:56 Now app is running perfectly
32:58 and tested in this app in physical device