2 fcfcfc147258 fcfcfc147258 于 2012.12.28 09:57 提问

android 连接打印机打印?

平板连接打印机打印,这个有谁知道呢,急急急急急求啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊

1个回答

lwq421336220
lwq421336220   2012.12.28 09:58
已采纳
public void dayin() {
        Socket s = null;
        Thread thread = null;
        Boolean isContect = false;
        InetSocketAddress isa = null;
        try {
            s = new Socket();
            isa = new InetSocketAddress("192.168.0.168", 8000);
            s.connect(isa, 5000);
            DataInputStream dis = null;
            DataOutputStream dos = null;
            if (s.isConnected()) {
                isContect = true;
                PrintWriter out = new PrintWriter(new BufferedWriter(
                        new OutputStreamWriter(s.getOutputStream(), "GBK")),
                        true);
                out.println(Constant.str_bf.toString());
                Toast.makeText(ThankTabActivity.this, "连接成功", Toast.LENGTH_LONG).show();
            }
        } catch (IOException e) {
            Toast.makeText(ThankTabActivity.this, "连接失败",Toast.LENGTH_LONG).show();
            e.printStackTrace();
        }
    }
Csdn user default icon
上传中...
上传图片
插入图片