hola amigos como estan navegando por la internet me encontre con un codigo para android que en lista los dipositivo bluetooth y se conecta al selecionar un dipositivo pero a mi me da el siguiente error
runtime execption can ' t create handler inside thread that has not called looper prepare el error se produce en el evento FormShow, aqui muestro el codigo completo
Código Delphi
[-]unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
Androidapi.JNI.BluetoothAdapter,
Androidapi.JNI.JavaTypes,
Androidapi.JNIBridge,
FMX.ListBox, FMX.Layouts, FMX.Memo, FMX.Edit, FMX.Objects, FMX.ListView.Types,
FMX.ListView, System.Rtti, FMX.Grid, Data.Bind.GenData,
System.Bindings.Outputs, Fmx.Bind.Editors, Data.Bind.EngExt,
Fmx.Bind.DBEngExt, Data.Bind.Components, Data.Bind.ObjectScope;
type
TForm1 = class(TForm)
reload: TButton;
Label1: TLabel;
ListView1: TListView;
Button1: TButton;
procedure FormShow(Sender: TObject);
procedure ListView1ItemClick(const Sender: TObject;
const AItem: TListViewItem);
private
public
targetMACAddress:string; ostream:JOutputStream;
istream:JInputstream;
uid:JUUID; Sock:JBluetoothSocket;
Adapter:JBluetoothAdapter; remoteDevice:JBluetoothDevice;
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.FormShow(Sender: TObject);
var
s:string;
i:integer;
list:TStringList;
begin
list:=TStringList.Create;
s:=checkBluetooth; if pos('disabled',s)<>0 then
begin
ShowMessage('Please turn on Bluetooth and Retry');
exit
end;
uid:=TJUUID.JavaClass.fromString(stringtojstring('00001101-0000-1000-8000-00805F9B34FB'));
list.Clear;
list.AddStrings(getbonded);
listview1.Items.Clear; listview1.BeginUpdate;
for i := 0 to list.Count-1 do
begin
listview1.Items.Add;
listview1.Items.Item[i].Text:=list[i].Split(['='])[0];
listview1.Items.Item[i].Detail:=list[i].Split(['='])[1];
end;
listview1.EndUpdate
end;
procedure TForm1.ListView1ItemClick(const Sender: TObject;
const AItem: TListViewItem);
begin
ShowMessage('You selected: '+Aitem.Text);
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
ShowMessage('Could not connect to BlueTooth device');
end;
if not sock.isConnected then
begin
ShowMessage('Failed to connect to Try again...');
exit;
end;
listview1.Visible:=false; label1.Visible:=false; reload.Visible:=false; end;
end.
cual puede ser el problema