Recent

Author Topic: LAMW: It is crash when I call jBluetooth1.GetRemoteDevice  (Read 1520 times)

Ritt

  • Newbie
  • Posts: 6
LAMW: It is crash when I call jBluetooth1.GetRemoteDevice
« on: March 13, 2019, 09:14:55 am »
Hi Everyone,
I used the the example "AppBluetoothClientSocketDemo1", the BLE device was founded, so I Call:

      try
         jBluetoothClientSocket1.SetDevice(jBluetooth1.GetRemoteDevice(deviceAddress));
         jBluetoothClientSocket1.Connect();
       except
         on E: Exception do ShowMessage(E.Message);
       end;

but it was crashed,
I try it in the android studio, it was work, how can I solve this probleam?
Thanks

Ritt

  • Newbie
  • Posts: 6
Re: LAMW: It is crash when I call jBluetooth1.GetRemoteDevice
« Reply #1 on: March 23, 2019, 12:33:22 pm »
I founded that in the jBluetooth.pas:
function jBluetooth_GetRemoteDevice(env: PJNIEnv; _jbluetooth: JObject; _macAddress: string): jObject;
var
  jParams: array[0..0] of jValue;
  jMethod: jMethodID=nil;
  jCls: jClass=nil;
begin
  jParams[0].l:= env^.NewStringUTF(env, PChar(_macAddress));
  jCls:= env^.GetObjectClass(env, _jbluetooth);
  jMethod:= env^.GetMethodID(env, jCls, 'GetRemoteDevice', '(Ljava/lang/String;)Landroid/bluetooth/BluetoothDevice;');
  Result:= env^.CallObjectMethodA(env, _jbluetooth, jMethod, @jParams);
  env^.DeleteLocalRef(env,jParams[0].l);
  env^.DeleteLocalRef(env, jCls);
end;   

The call the JNI function 'GetRemoteDevice',  but there is no function with name 'GetRemoteDevice' in the jBluetooth.java.   I think this should be change to 'GetRemoteDeviceByAddress'.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW: It is crash when I call jBluetooth1.GetRemoteDevice
« Reply #2 on: March 23, 2019, 05:05:28 pm »


Fixed  "jBluetooth.java"!!!

Thank you!!!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

 

TinyPortal © 2005-2018