I develop an application which has several tasks like report generator, show history etc,
now I want to add a method by which I can directly print these report from the printer on local network.
so I need that there is a Button named "Print" now when user click this button then my given text is directly print from the shared printer in local network by wifi connection.
my printer IP is 192.168.1.50
Now How i can do this by coding.
please reply
Thanks
Any device connected to a network will communicate via their IP and Ports / sockets. The simplest way to connect via telnet or socket and write the data to their socket buffers.
try
{
Socket sock = new Socket("192.168.1.222", 9100);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.println("HI,test from Android Device");
oStream.println("\n\n\n");
oStream.close();
sock.close();
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
One solution is using Google Cloud print with android
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