Hi All.
I have this code in Java:
Now all work method, etc... but i will want intercept handleMessage ( looper calls dispatchMessage on message target which is a Handler ) it should be pretty simple.
So i write this code in JavaObject:
what is missing ?
Thank you very much
Marco
I have this code in Java:
B4X:
import com.zj.btsdk.BluetoothService;
BluetoothService mService = null;
mService = new BluetoothService(this, mHandler);
...
mService.connect(con_dev);
mService.sendMessage("Congratulations!\n", "GBK");
....
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case BluetoothService.MESSAGE_STATE_CHANGE:
switch (msg.arg1) {
.......
};
Now all work method, etc... but i will want intercept handleMessage ( looper calls dispatchMessage on message target which is a Handler ) it should be pretty simple.
So i write this code in JavaObject:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim btdisponibile As Boolean = stampante.RunMethod("isAvailable", Null)
If btdisponibile Then
stampante.RunMethod("connect", Array(MacBluetooth))
stampante.RunMethod("sendMessage", Array("Test", "GBK"))
........
End If
End Sub
Sub stampante As JavaObject
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim handler As JavaObject
handler.InitializeNewInstance("android.os.Handler", Null)
handler.CreateEventFromUI("android.os.Handler.Callback", "Callback" , Null)
Dim ir As JavaObject
Return ir.InitializeNewInstance("com.zj.btsdk.BluetoothService", Array(ctxt, handler))
End Sub
Sub Callback_Event (MethodName As String, Args() As Object) As Object
Log(MethodName)
Log(Args(0))
Return Null
End Sub
what is missing ?
Thank you very much
Marco