2
我想與Android連接到德爾福藍牙打印機,使用由David I.在Bluetooth Paired Devices Browser例子描述的技術如何使用Android連接藍牙打印機?
我的打印機是Panda BIXOLON SPP-R200II:
我得到的錯誤:
"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;