Search code examples
androidandroid-emulatorandroid-wifi

wifi printing in android


I want to print file using wifi printing in my android application.I have scanned wifi printer and i am having wifi printer IP address . Now how can i transfer file from android phone to printer to print it ? I am using following code to transfer file to printer `public void uploadFile(File fileName){

     FTPClient client = new FTPClient();
    try {
        client.connect(FTP_HOST,21);
        client.login(FTP_USER, FTP_PASS);
        client.setType(FTPClient.TYPE_BINARY);
        client.changeDirectory("/");
        client.upload(fileName, new MyTransferListener());
    } catch (Exception e) {
        e.printStackTrace();
        try {
            client.disconnect(true);    
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

}`

Can anybody help me ? Thanks in advance.


Solution

  • I think you can might do it without sending whole file, just pick the Strings from the file and make connection with the wifi device, send the text to the device, it will print it. I have done same thing with the bluetooth printer.