I am developing an Android application were I am supposed to get the data from a database in csv/txt file format and later I have to send the files to a wifi printer.
Do anyone know how I might get started doing that?
The answer was finally easy :
Socket client = new Socket(_IP, PORT);
oStream = new PrintStream(client.getOutputStream(), true, "UTF-8");
oStream.println("-------------------------------------------------\r\n");
oStream.println(" NAME : DEMO CLIENT\r\n");
oStream.println(" CODE : 00000234242\r\n");
oStream.println(" ADDRESS : Street 52\r\n");
oStream.println(" Phone : 2310-892345\r\n");
oStream.println("-------------------------------------------------\r\n");
oStream.flush();
oStream.close();
client.close();
You could read a data from database to a file directly. and then you can connect the printer via sockets or wifi. And then pass on to the printer.
There are bunch of projects on github, maybe you can look at them, for example EasyPrinter.
You can do this using sockets. You can get examples in these links http://examples.javacodegeeks.com/android/core/socket-core/android-socket-example/ Example: Android bi-directional network socket using AsyncTask
and you can google it. (Socket programming via java and android examples)
So first you must get your printer ip and port and send data to printer via a socket. To be ui friendly, you can create a setting form where you can set available printers ip and port
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With