如何使用Android连接蓝牙打印机?
我想使用David I在示例中描述的技术,通过Delphi将Android连接到蓝牙打印机 我的打印机是: 我得到一个错误:如何使用Android连接蓝牙打印机?,android,delphi,bluetooth,android-bluetooth,Android,Delphi,Bluetooth,Android Bluetooth,我想使用David I在示例中描述的技术,通过Delphi将Android连接到蓝牙打印机 我的打印机是: 我得到一个错误: "java.io.IOException: read failed, socket might closed or timeout, read ret: -1" 通过sock.connect 这是我的密码: procedure TForm1.ListView1ItemClick(const Sender: TObject; const AItem: TListVie
"java.io.IOException: read failed, socket might closed or timeout, read ret: -1"
通过sock.connect代码>
这是我的密码:
procedure TForm1.ListView1ItemClick(const Sender: TObject;
const AItem: TListViewItem);
begin
ShowMessage('You selected: '+Aitem.Text);
// depending on the bluetooth device selected - do something with it
targetMACAddress:=Aitem.Detail;
if trim(targetMACAddress)='' then exit;
Adapter:=TJBluetoothAdapter.JavaClass.getDefaultAdapter;
remoteDevice:=Adapter.getRemoteDevice(stringtojstring(targetMACAddress));
sock:=remoteDevice.createRfcommSocketToServiceRecord(UID);
try
sock.connect;
except
on E : Exception do
ShowMessage(E.Message);
end;
if not sock.isConnected then
begin
ShowMessage('Failed to connect to Try again...');
exit;
end;
listview1.Visible:=false; // hide the chooser
label1.Visible:=false; // hide the chooser
reload.Visible:=false; // hide the chooser
end;
与蓝牙设备进行的所有通信必须通过线程执行。
我在Android Studio中为Delphi转录了一个项目,使用了线程,一切正常。
不要使用计时器,请使用TThread对象