at first, thank you so much for maintaining this fantastic extension. I only started using it.
I use v4.5.0, with permissions POST_NOTIFICATIONS, FOREGROUND_SERVICE, WAKE_LOCK, RECEIVE_BOOT_COMPLETED, FOREGROUND_SERVICE_CONNECTED_DEVICE, CHANGE_NETWORK_STATE, BLUETOOTH_CONNECT, BLUETOOTH_ADVERTISE, BLUETOOTH_SCAN.
I want to make a background auto-(re)connect service and I want to use the Bluetooth connection in the foreground to exchange some data once it’s established. I must’ve overlooked some vital information because it isn’t working for me. If I enable the block in the foreground process to make the BluetoothClient1.connect() and disable the CreateProcess() one line below, it works perfectly, however if I create a background process for backgroundbg(), it does not work and there is no Bluetooth error, either.
If you would be so kind to take a look, I’d really appreciate it.
Is BluetoothClient.Connect() expected to work from an Itoo background process, or is it only supported from the foreground Activity?
The reason you see nothing appear on the Label1 is because when the procedure event BluetoothClient1_ClientError tries to call the debug procedure, the debug procedure fails because it touches the Label1 component which belongs to the UI. (UI cannot be touched from the background).
To fix the problem, simple rename procedure debug --> ui_debug. This would indicate to the extension that the procedure must be processed on the UI thread.
To keep the Bluetooth Client connection working in the itoo background, you must move your whole bluetooth functionality to Itoo styled blocks.
I think I got it: I even can’t read the BluetootClient1.Connected() function in my “foreground” part, because it’s simply not the same instance. Probably that’s why my code fail to follow the BT status. Other than that, I renamed my debug to ui_dbug but still did not get any errors; maybe the connection succeeded, but I can’t check it right now. I’ll re-design my code and test.
Dear @Atomgep, you might also give a look to this example of mine:
Here the BT is handled by itoo (i.e. in background).
Moreover in this example I wanted to see iwhether the classic BT and the BLE were capable to live together, but you can extract only the part you need.
Cheers.
Thank you so much for your reply, Kumaraswamy! I will follow your example to set the Location Sensor properties first and test it on my device. Appreciate your great work on Itoo!
thank you indeed, I read the page, excellent work! Unfortunately, in the meantime I’m having a strange issue, I use Android 14 and I tried v4.5.0 and v4.4.2 version of Itoo, with a dead simple example that still does not work. No BT this time. These are all my blocks, I don’t think I can’t simplify it more… I left the Itoo settings on default in both versions.
Shouldn’t the run(x) functions run at least once? The counter always shows zero. As long as I don’t understand what’s happening, I can’t go for more complex code.
Hello @Atomgep, are you testing it in the companion or the compiled APK? Itoo does not support the companion, so it is likely the run never got executed.
Dear @Atomgep, if I compare my example with what you've done, I see many differences.
The most evident one is that you never activate the clock. And do not forget to "register" the clock event.
Please take a look to my Background(x) function here below (don't consider the BT activation, but only the red circled parts):
You see that the clock is activated by the Background(x) function and the service routine is called Tick, which does the job (for you it should set the "counter" variable):
EDIT after a recap with @Kumaraswamy, please check the extension version you 're using: probably the Registter for event is deprecated. But the timer activation hint, remains
I am working on a background project using Itoo v4.5 (Sky). I want my background task to survive and automatically continue running after the device reboots.
I have attached my current block setup below. As you can see, I am using a simple counter with StoreProperty and FetchProperty to keep track of the run times, and a Clock in the background to handle the loop.
Currently, Itoo1.CreateProcess successfully ignites the Boot_Waked procedure in the foreground, but nothing happens after the phone restarts.
Since Itoo v4.5 has deprecated RegisterEvent, could you please guide me on how to achieve auto-start on boot with this setup?
Do I need to call a specific block in the foreground to register the "Boot_Waked" procedure for boot autostart?
Or should the background process automatically resume by itself under the v4.5 architecture?
Any advice or code snippets would be greatly appreciated. Thank you for this amazing extension!
Hi @Kumaraswamy,
I have returned to using itoo sky 4.4 first, and it is running normally using SaveProcessForBoot. I hope that itoo sky 4.5 can also use SaveProcessForBoot again. Thank you.
I am trying to fix this aplication because to send messages in background I can’t. This aplication is about detect drops and send a message if you can see what is going on.
Thanks so match for answer the last time I post!!!
Yes I put permissions to the SMS. My version of Android of my mobile is 15 and in the app is 5+. And I remove the ui_. Also I put the accelerator to true. But It doesn’t work, only apears a notification but when I throw the mobile it doesn’t send a message. Also a thing that I see is that when I do it like in foreground it works like only two times and doesn’t work anymore. If you find the solution you are god. Thanks for all the support. I send you here the new code change it.