【发布时间】:2021-06-16 08:37:13
【问题描述】:
我想通过蓝牙将终端应用程序中的数字数据作为 ASCII 发送到 Android 应用程序,并在 Android 应用程序内部将 ASCII 数字数据转换为字符。
我只找到了一个解决方案,但它读取为单个字节。 我为 Android 应用编写了这个命令来获取数据:
InputStream stream;
if (stream.available() > 0) {
int a = stream.read();
int x = Character.getNumericValue(a);
this.mmOutStream.write(x);
this.mmOutStream.flush();
}
这个命令
int a = stream.read (); /// 128
它将数据作为 ASCII 码并扔进一个
这个命令
int x = Character.getNumericValue(a); /// 1 2 8
ASCII 转换为字符,但给出单个字节的数据。 也就是我把数字作为 ASCII 给出,例如数字 128 128 转换为 1 2 8。 但我要128,他却一一给我。
【问题讨论】:
-
我不明白你想要达到什么目的.....
标签: java android character ascii inputstream