I have created a simple app in which I give print command to printer but nothing happens.
Here is my code:
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Socket socket;
try {
socket = new Socket("xxx.xxx.xx.21", 515);
PrintWriter outputStream = new PrintWriter(socket.getOutputStream());
outputStream.println("\fThis is a test print");
outputStream.close();
socket.close();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
When I run this code it works but doesn't print anything on printer.
Configuration details:
I have my laptop, android device & printer in same network. I tested IP addresses of all the 3 as well as port number of printer. Also, I pinged to printer's IP address from my laptop command prompt so I get reply but when I connect through device nothing happens.