相关疑难解决方法(0)

如何在Android中的蓝牙打印机上打印图像?

我必须在热蓝牙打印机上打印一些数据,我正在这样做:

String message="abcdef any message 12345";
byte[] send;
send = message.getBytes();
mService.write(send);
Run Code Online (Sandbox Code Playgroud)

它适用于文本,但不适用于图像.我想我需要获取byte[]图像数据.我尝试以这种方式获取图像的数据:

Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.qrcode);
ByteArrayOutputStream stream=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream);
byte[] image=stream.toByteArray();
Run Code Online (Sandbox Code Playgroud)

不幸的是,打印机会打印出许多奇怪的字符(大约50厘米的纸张).我不知道如何打印图像.

我想尝试获取位图的像素,然后将其转换为a byte[]并发送它,但我不知道该怎么做.

谢谢

更新:

经过这么多时间,我这样做:我有一个名为print_image(String file)的方法,它获取我想要打印的图像的路径:

private void print_image(String file) {
    File fl = new File(file);
    if (fl.exists()) {
        Bitmap bmp = BitmapFactory.decodeFile(file);
        convertBitmap(bmp);
        mService.write(PrinterCommands.SET_LINE_SPACING_24);

        int offset = 0;
        while (offset < bmp.getHeight()) {
            mService.write(PrinterCommands.SELECT_BIT_IMAGE_MODE);
            for (int x = 0; x < bmp.getWidth(); ++x) {

                for (int k = 0; k < …
Run Code Online (Sandbox Code Playgroud)

java android bytearray bitmap bitmapfactory

49
推荐指数
4
解决办法
6万
查看次数

适用于Android的蓝牙和WIFI打印

我们需要一台可以通过蓝牙或wifi连接到Android手机的便携式打印机(手持设备,这很重要).

我目前所知道的:

  • 这次没有适用于Android的标准打印SDK
  • 有一个名为iPrint SDK的非官方SDK.有没有人通过wifi或蓝牙试过?它有用吗?
  • Printershare还声称可以通过程序化方式获得.我可以为每部手机支付5美元的一次性费用.它有很多支持的格式.你有没有尝试过任何手持设备?我向他们询问了支持的蓝牙打印机列表(因为它有一个菜单项"搜索BT打印机"),但他们没有回答.

我已经问过上面需要知道的事情:

  • 你如何从你的Android应用程序打印?
  • 你用的是什么类型的打印机?
  • 是否计划在标准的Android SDK中包含打印?什么是路线图?它现在可用作Beta还是其他什么?
  • 如果我们以某种方式(我不这么认为)通过蓝牙构建自己的打印解决方案,您能推荐标准和协议来检查和学习吗?

printing android bluetooth printers wifi

43
推荐指数
4
解决办法
6万
查看次数

在Android中打印API

我下载了一个名为PrintShare的实用程序,它允许用户通过无线或参与PrintShare网络的计算机将打印机,联系人列表,日历等内容打印到打印机上.

我想让我的Android应用创建一个文本文件,然后将该文本文件发送到与PrintShare共享的打印机.

是否有用于在Android上打印的API?

谢谢迈克

printing android

5
推荐指数
1
解决办法
2万
查看次数

Android:在SPP蓝牙设备之间切换

我有两个不同的蓝牙打印机.Bixolon SPP-R200和Fujitsu FTP-628WSL110.我可以分别连接到每个(使用三星Galaxy SII)打印,断开连接并重新连接就好了.但是,如果我关闭Bixolon并尝试与Fujitsu配对(之前未配对,Bixolon仍然配对),那么当尝试连接到创建的套接字时它会失败.相反的方式.

这是错误消息:

07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380): Failed to connect to rfcomm socket.
07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380): java.io.IOException: Service discovery failed
07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380):  at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:406)
07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380):  at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:217)
07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380):  at MyApp.BluetoothConnection.connect(BluetoothConnection.java:171)
07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380):  at MyApp.AbstractBluetoothPrinter.connect(AbstractBluetoothPrinter.java:34)
Run Code Online (Sandbox Code Playgroud)

这是代码,它使连接尝试,在解释的情况下失败的行是btSocket.connect(); - 例外见上文:

/** Is set in connect() */
private BluetoothSocket btSocket = null;
/** Is set prior to connect() */
private BluetoothSocket btDevice;

public boolean connect(){

        try {
            btSocket = btDevice.createRfcommSocketToServiceRecord("00001101-0000-1000-8000-00805F9B34FB");
            if (btDevice.getName().startsWith("FTP")) {
                //Special treatment for the …
Run Code Online (Sandbox Code Playgroud)

android bluetooth spp

2
推荐指数
1
解决办法
3651
查看次数

标签 统计

android ×4

bluetooth ×2

printing ×2

bitmap ×1

bitmapfactory ×1

bytearray ×1

java ×1

printers ×1

spp ×1

wifi ×1