Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect a network printer over Android?

I want to code an Android app, which will connect to a network printer with a specific IP address, and then make a printing.

For printing I know that I need to write my own Postscript for specific files types, and connecting to a network is not a problem over WIFI.

How to connect to the network printer?

like image 483
Fallenlight Avatar asked Jun 10 '11 01:06

Fallenlight


People also ask

Why can't my Android phone find my printer?

Check the printer connection status: Make sure the wireless signal is on, and the printer is connected to the same network as your computer or mobile device. If your printer has a light next to a Wireless icon or button , make sure the light is on. If it is off or blinks the printer is disconnected from the network.

Can I print directly from my Android phone?

You can also print directly from your open documents, like with Android, if your smartphone and printer are connected to the same wi-fi network. To print from a Windows tablet, swipe to the left to bring up the Charms bar and then select Devices.


2 Answers

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();
    } 
like image 128
ReachmeDroid Avatar answered Sep 18 '22 08:09

ReachmeDroid


You might be able to use lpdspooler, that is, if the printer supports LPR/LPD. If you can give some more details about the environment (printer, etc), I might be able to give more information.

like image 20
AC2MO Avatar answered Sep 21 '22 08:09

AC2MO