Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I send csv/text file from an Android phone to a wifi printer?

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?

like image 667
user777221 Avatar asked May 31 '11 07:05

user777221


3 Answers

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(); 
like image 192
Stathis Andronikos Avatar answered Nov 18 '22 00:11

Stathis Andronikos


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.

like image 23
blganesh101 Avatar answered Nov 17 '22 22:11

blganesh101


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

like image 1
A. Zalonis Avatar answered Nov 17 '22 23:11

A. Zalonis