It’s just like passing the data you want to be printed.. Hello @ahmedibrahimm:disqus, I we talked via email few days ago. public static byte[] RESET = {24}; Power the Arduino board, turn on Bluetooth on the Android phone and search for Bluetooth devices nearby: the JY-MCU module will present itself as HC-06, the pairing password is 1234. By the time I sent in my feedback, the printer was only printing once however, after abit of tinkering, I moved the closeBT() method to be executed just after the first receipt has been printed, and it is now working. This tutorial will consider that you are going to setup your environment on Windows machine having Windows 8.1 operating system. @Rolex, I think you can find it in amazon, alibaba or ebay.. Where can i buy/order MP300 mobile printer?plz help…. Hi @Muhitun, thank for the kind words! Can you help me? in my website with Login only unique id ans also store every chat history in my database;i can’t understand how to do please give me some guideline. I need to be able to format printed text to BOLD, Italic and underline. About your issue, have you tried the ‘close’ button before trying to print another one? hello BluetoothPrintImage buy the code to print the image but leaving some characters and not print the image, I wonder if I can help with the solution. Hey @disqus_nYnzGXSTKm:disqus , thanks for the report, but does your app crashes? Things worked well upto socket creation but on connect() call exception occurs like this ” read failed, socket might closed or timeout, read ret: -1 “. Step 2: Type any text in the text box or EditText. if you have any sample like this please give me. public static byte[] FONT_WIDE_OFF = {15}; !”, ★★★★★ “This just saved me so much time that I will drink a beer for your sake, and I would pay you one if I'd have the chance. How to import to Android Studio. plissss thanks. Simply connection to an iPhone, Android, Tablet, PC or Mac. and if he is necessary ? how to set that dimension??? Hello @heminshah:disqus, we only tried it with Bluetooth connection. can you help me for change sdk. Excellent tutorial! public static byte[] FONT_BOLD_ON = {27, 85, 49}; when i implement your code it seems that the send and close button is not working. Is there any other example for printing via network printer, @miquelmas:disqus Is it possible to have the source code of the app ???? hi! Do you convert your data in a file or something like that. Do you have a USB printing example source code for this printer? It was very usefull, Using Epson T70i(Thermal) printer, We can print images via Android Wifi Connection :D. Hey @disqus_gTHibeWSII:disqus, good to know you can do that with the help of our code, would you tell us specifically how you did print images? Hi Mike, PLEASE NOSE SI revise the problem that I mentioned AND SEND THAT YOU WANT PRINTER PRINT, IS URGENT PLEASE THANKS. I am trying to write an APP to print in TPCL mode. BLUETOOTH WIRELESS - Popular classic bookshelf speakers now can be enjoyed without the hassle of wires. If it works correctly, you can just catch these logs. but i am facing a problem, i have another bluetooth printer and its not working with it ? This is great tutorial, thanks . There is no issue with the printing. Is possible to adapt this code to an application based in c#? hi i did the code for print image get my email Wesleymontaigne@hotmail.com but pdf i can’t to do this. LEVEL 1 is the complete source code of our tutorial above. I will reply with the contact information of our supplier. Please note that you have to pair your Android device (in your Bluetooth settings) and Bluetooth printer before running our source code. Thanks …. java.lang.NullPointerException: Attempt to invoke virtual method ‘void java.io.OutputStream.write(byte[])’ on a null object reference, THank you so much… its work for me… my model printer is ZJ-5802LD. So device object is null and so further dependencies. } About your convern, would you specify the error or logcat message that you see there? Hi. Hello, yeah. Here’s the source code version where you can print images (see output video demo on section 3.0 above). Add an alignment tag on a same line of text implicitly create a new column. is this the only version (LEVEL 2) of the downloadable file? To install Java JDK,take a references of Android environment setup. public static byte[] SELECT_CYRILLIC_CHARACTER_CODE_TABLE = {0x1B, 0x74, 0x11}; mmOutputStream.write(PrinterCommands.INIT); please help, Hi @takizwanarin:disqus, what exactly is the problem you’re facing, can you tell us some error messages? It shows the paired devices and shows “Bluetooth device found” in EditText field. Please help me sir, Hi friend, do you have some example to Xamarin with VS? Step 13: closeBT() method in Step 12 will not work without the following code. We don’t have your devices to test it out. For most compatible cars or aftermarket stereos, simply plug in your phone using a USB cable. Thanks @Tony! And this UUID is our android Device Ya Bluetooth Printer , public static byte[] FONT_UNDERLINE_ON = {27, 85, 85}; 07-18 16:48:23.669: W/System.err(12643): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:995) mmOutputStream.write(PrinterCommands.FONT_HI_ON); Hi @disqus_O6v8KoBrRe:disqus, what printer model are you using? Download the source code by clicking the “Buy Now” button below. Images must be small and less than 10KB in size only, anything more than that, the printing will fail. All of the Bluetooth APIs are available in the android.bluetooth package. 07-18 16:48:23.669: W/System.err(12643): at android.view.View.performClick(View.java:3660) I will give you the contact information of our supplier. Thank you in advanced. Please let me know if any have got any answer. Is this code work only for this printer or can work for all ? :D. Hi Murugan, did you already try it using a different character encoding? You might also want to play with this line of code: i mean in this code i have to only change the name of my Bluetooth device ? Thanks for this awesome project! 4.3 LEVEL 2 Source Code. Hi, i have a Zebra printer, ZQ500 Series. 07-18 16:48:23.639: W/System.err(12643): java.lang.NullPointerException here is the log. and what brand and model your android device. Hello @deepakdonde:disqus, we only tested it in text and image. After done all above steps perfectly, you must get finish button and it gonna be open android studio project with Welcome to android studio message as shown below. Would you explain your situation, why do you want to print PDF? a very nice example of working IBluetooth bluetoothProxy = BluetoothAdapter.getDefaultAdapter().getBluetoothService(null); Being a new programmer, I can’t find a solution. Hello @megatfive:disqus, thanks for the kind words! It may not work with your kind of printer. Hello @disqus_jINABdnw23:disqus, I haven’t tried it, buy I’ll share it once I did it. “java.io.IOException: read failed, socket might closed or timeout, read ret: -1”. Can u explain me the concept ‘beginListenForData()’ function.. i.e how it checks whether data is sent for printing. Thank you. On an Android powered phone, enter the Tethering and Hotspot Menu. Order ID#24989. So please tell me how to print this. Android 4.3 (API level 18) introduced built-in platform support for Bluetooth Low Energy (BLE) in the central role and provides APIs that apps can use to discover devices, query for services, and transmit information.. Common use cases include the following: Transferring small amounts of data between nearby devices. Thank you so much for your work, and for sharing it, keep going with your awesome job!”. Hello @disqus_n1f2NimhSp:disqus, source code is almost still the same, the only change is before, I developed it in Eclipse, now it is developed in Android studio. This code will simply let you connect to the Bluetooth printer, type a text that you want to be printed and click the “send” button to print. Your code working perfect. my log:- Hi @dibbstar, good to hear it works on your printer devices! Hello @amdad hossain, I really can’t answer that question. hello, thank you for proving such a wonderful post, my question is, how would I go about incrementing the text size when print is executed? ~ Linus Torvalds, Co-Founder & Technology Advisor, Microsoft Corporation, Our website contains FREE Android programming tutorials by, https://i0.wp.com/www.androidcode.ninja/wp-content/uploads/2013/03/android-bluetooth-printing-example-code-with-actual-printer-device.jpg?fit=800%2C450&ssl=1, https://www.codeofaninja.com/wp-content/uploads/2016/06/codeofaninja-logo-100x100-op-80x80.png, Android Bluetooth Printing Example Code with Actual Printer Device. hi thanks for reply, it is a zebra rw 220 printer prints this way, I can change in the code, if I can help. I have a small project here, but the default font size on the printer does not please the client …. -> Header a bit bigger, bold and center aligned I haven’t received any download link. plz reply me. Hi! HI @alexbrsp:disqus, thanks, good to hear you liked this example! It is zebra 220, in the code that I have to change if I can help, I will read the manual of the printer and the resolution you have is 203 bpi, with width of 56mm and 914 mm long. I need your code for android application so please me i am waiting for your response. Great work!!!! If it is, I’ll reply to you here. 07-18 16:48:23.669: W/System.err(12643): at android.app.ActivityThread.main(ActivityThread.java:4517) 07-18 16:48:23.669: W/System.err(12643): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) -> setting text right/ left aligned. Second point is that all the required tools to develop Android applications are open source and can be downloaded from the Web. Put it below the sendData() method code block. http://www.oracle.com/technetwork/developer-tools/maf/overview/index.html, https://blogs.oracle.com/mobile/entry/maf_2_3_release, i have same problem my send and close buttons not perform any action so please i was used same above code in my project but we face issues so any one face this type of issue. Can I use this code for Woosim WSP i350 printer? Can someone help me out on fixing this one? To show hello word, we need to call text view with layout ( about text view and layout, you must take references at Relative Layout and Text View ). public static byte[] SELECT_FONT_25 = {27, 75, 49, 49, 13}; Thanks! ok, works great, but i want print a pdf file, what can i do? Thanks for letting us know! I have a question, is it possible to print a PDF by this code? did you used in this program. Hello @disqus_jOagGBxHmJ:disqus, what part of the code will you use decimal/hexadecimal? Can u share Printer shopping cart link..Because i searched lot i am not getting .,pls.. Hello @ananddoodleblueandroidteam:disqus, we are working on an android shopping cart source code. But, as the mobile is connected with printer it always shows print successful though it is not printing for unavailability of paper. However, I don’t know how to do that too, I haven’t tried it yet. Hello @disqus_o0249IY8l8:disqus, unfortunately, I’m unable to test it with other printers. Because I am new in android. 07-18 16:48:23.669: W/System.err(12643): at java.lang.reflect.Method.invoke(Method.java:511) and barcode and images Hi Mike…. Both libraries are available on jcenter. what is the b,,im not understand ? Hi! my bluetooth printer Zjiang POS Thermal Printer 57.5mm – ZJ-5890K – Black. When I attempt to print the second time, I get the error message below: Hello @disqus_IxHvjtuQDV:disqus would you show us your logcat message? Need to run the program by clicking Run>Run App or else need to call shift+f10key. You’re welcome! Hi, any luck with making print images? Hi Mike!! You have to contact your printer manufacturer about its configuration for printing arabic characters. Your email address will not be published. pls how can i print a page of displayed activity directly to the Bluetooth printer. THank you so much.. it helped me a lot.. the only problem I had.. was that this permission was missing in the in the manifest, without it I counldn’t print. you can also just concatenate the values of those edit text to be printed…, thanks you very much boss u cleared me all concept about …, Hi am getting connection refused exception any IDEA. Thanks for the bluetooth prinitng code. public static byte[] FONT_UNDERLINE_OFF = {27, 85, 117}; Hello @disqus_KRrNtzO1Tm:disqus, unfortunately, I don’t have that kind of printer. After setup, depending on your car, either the phone will automatically connect or the Android Auto app icon will appear on your car display. “First do it, then do it right, then do it better.” Great tutorial, definately gonna try it.. Thank you very much sir!”, ★★★★★ “Great work!!!! please send me download file if it is possible. I only tested it with the device mentioned above. I have a printer DPP 250, the program is working good.. and conncet whith the printebut the print does not come out! See this part of the code…, MP300 might not be the name of your bluetooth device…. Hello @kamullick, are you sure your Bluetooth printer name is IBluetooth? Sir want change is reqiured in your code” bluetooth send data to bluetooth printer ” My goal is to send file from one andriod phone to another andriod phone i know you solve my problem as soon as possible. I’m sure this will be useful for Zebra iMZ printer users! I have fount tens of code blocks that work well in ESC/POS but nothing to print in TPCL via Bluetooth. I want print a image, but i can wait and go on searching in the web Hello Akin, pls I have not been able to make this code work, can you help? Thanks for the code. I am using samsung galaxy pocket with Blue Bamboo printer but it does not send any command to the Printer it only write Bluetooth Device found. Hi! The source code can let you browse an image and then print it in the Bluetooth printer. Hello @benignovera:disqus, what printer model are you using? I need your help if its possible. HI,why this sample can’t show traditional Chineseword of use UTF-8 Type? Some good people might want to contribute to this post and add that functionality. Android platform includes support for the Bluetooth framework that allows a device to wirelessly exchange data with other Bluetooth devices. I get the records from the SQLite database, and assign them to that variable msg. thank you. It will not work without the following code. My PC use source code from https://www.dropbox.com/sh/31o42beyy1y3gv1/R4sPCdOs7G What is my problem? PLZ HELP ME, thank you sooooo much, it’s also worked for me. But I am facing formatting issues, the content is printing continuously not line by line. Hi, does this code supports multiple phones sending print requests to the same printer simultaneously? Step 6: We will set the onClickListener of our open button. i have rongta printer RP80 without bluetooth or wifi. Please mike I have tried to implement this code in oracle mobile application framework (android version) environment but it couldnt connect with rpp300 printer .I use oracle mad 2.3 to developed android applications. 00000001 –> to dec = 1. Hello Mike , Great work ! Thanks a lot. Send an email to mike@codeofaninja.com with a subject “Bluetooth printer by codeofaninja.com”. The LEVEL 2 source code can print small images. Is there a way to align text to right left as a table. We are looking for driver for following device below and need to print PDF doc from tablet to printer. Sir you are saying right but i want to simply send data from one device to another .sir kindly give me the code and thanks in advance, Hi @disqus_4YWarVSi2i:disqus, sorry but this post does not cover your request, but a code here might help you http://stackoverflow.com/a/6274660/827418. mmOutputStream.write(PrinterCommands.FONT_HI_ON); ★★★★★ “Learning to write programs stretches your mind, and helps you think better, creates a way of thinking about things that I think is helpful in all domains.”, ★★★★★ “In fifteen years, we'll be teaching programming just like reading and writing ... and wondering why we didn't do it sooner.”, ★★★★★ “Thank you so much, it really helped me a lot, though I have encountered errors but I definitely pulled it out. I’m using a Zebra iMZ printer. Please check. i just stubble on this today!!! 07-18 16:48:23.669: W/System.err(12643): at dalvik.system.NativeStart.main(Native Method). If you like, you can close this window using top-right cross button. When the phone appears on the list of devices, Tap to connect. Can possible to print in A4 size paper using Bluetooth??? Unfortunately, we are unable to test it on that kind of printer because we don’t have one. Studio sound quality - Naturally fine tuned sound reproduction from 4 inch bass and 13mm Silk dome tweeter. How to format the string? I really appreciate you getting back to me on this. Regards. What error message in the logcat do you see? Hi @kadirleblebici:disqus, thanks for visiting, are you sure your printer is capable of printing russian characters? Hope to hear from you soon. I m Trying to build Chat app. do you know if the code will work on it? mmOutputStream.write(PrinterCommands.SELECT_FONT_25); escPosCharsetId may change with printer model.Follow this link to find escPosCharsetId that works with many printers. Need to buy the same printer model we used above? Hi @disqus_TaUs88ROtP:disqus, thanks for telling us about this instance, but did it print when you put a paper? How can I print HTML text to format the content/text? it was so awesome. Awesome it works with any other printer too!!! in a new installation frame should ask Application name, package information and location of the project. i buy mobile thermal printer This sensor monitoring application is designed using Android Studio. could post t your source code. public static final byte[] AUTO_POWER_OFF = {27,77,55,54,53,52,48,13}; it save a lot of my headache. SIr i try this code before basically major problem in this code is “uuid” is not present .SIr tell me what changes is reqiured in your project ” Bluetooth send data to Bluetooth printer “. Ok, thanks a lot! You’re welcome @me@meshileyaisrael:disqus! if Yes, could you send me the old version ? Also this printer is available in India ? Do you find the solution ? My goal is to send file from one andriod phone to another andriod phone .Sir i know you solve my problem plz sir reply me as soon as possible.thanks, Sir what change is required in your code “bluetooth send data to bluetooth printer” My goal is to send file from one andriod phone to another andriod phone and i know you solve my problem kindly answer me as soon as possible. If yes, could you please share the code to do this. your android code is very good for text, but i want print a picture or a file, please help me, thanks! Please let us know if you did it! What will you get? We haven’t tested this to print PDF content. Hello Good Citizen, I was trying to print dynamically created data from sqlite database, but I don’t know how to change the code of Mike Dalisay to do it. mmOutputStream.write(PrinterCommands.SELECT_FONT_25); public static byte[] FONT_HI_OFF = {29}; @disqus_Wy7mfWMI3I:disqus our LEVEL 2 source code above can do it. If you are installing Android Studio on Mac or Linux, You can download the latest version from Android Studio Mac Download,or Android Studio Linux Download, check the instructions provided along with the downloaded file for Mac OS and Linux. public static byte[] SEND_NULL_BYTE = {0x00}; IMPORTANT NOTE: This code was only tested with the printer we specified above. Hi @e256105adfdcaa924ee0bca596d75070:disqus, I think it really needs pairing since this is the industry standard for bluetooth. 07-18 16:48:23.669: W/System.err(12643): at com.example.bluetoothprinter.MainActivity.openBT(MainActivity.java:156) Dear Mr.Mike is the UUID is standard ? Many thanks. iIm having a problem in some device, it is working fine in Sony xperia and samsung galaxy, but not in Myphone and acer tablet. public static byte[] INIT = {27, 64}; Recently, I was asked to make a program for printing some data to a small or handheld Bluetooth printer device. Hi Jr Good, I have also the same problem, did you find the solution? This article will detail how to make a simple bluetooth application using Android Studio and demo it using an Arduino to toggle an LED and send data back-and-forth. Hello @elvalelucho:disqus, you’re welcome! Download at your own risk. I hope you try it and let us know. Connecting to an iOS or Android device. 1 thermal printer and 1 dot matrix printer and both of the printer is not working. Which printer do you use(printer company name and also model number)? it doest’n connect to the printer.. Hi @igimaster:disqus, can you show us what the logcat says? I would love to play around with this application, I am Trying to print a Receipt after every transaction (payment in my case). Before Writing a Hello word code, you must know about XML tags.To write hello word code, you should redirect to App>res>layout>Activity_main.xml.