Open Source • Background Tasks: Itoo 🚀

For that, you would need to move the entire BluetoothLE functionality over to Itoo, or the bleBackgroundReg procedure.

That means, move the ConnectWithAddress functionality, register an event for BluetoothLE's Connected event, and call RegisterForBytes from there. These three things should happen from the Itoo's background procedure (bleBackgroundReg) procedure

1 Like

INCREDIBLE! Amazing work @Kumaraswamy thank you so much for the guidance.

Paying it forward by sharing what I have working here. I was able to offload BLE to a background process. Next step: figure out how to exchange data between background and foreground process.

2 Likes

That's amazing, here is a resource that could further help you:

It will give you more idea of how Itoo works and a few things about application to foreground/background process communication.

1 Like

I tried changing Simple Notification id's value, but still Simple notifications created by Itoo NOT opening the app when clicked.

Hello, I want try Itoo, I instaled Itoo extension ok

I view the images in the top
I can not found
Itoo1.CreateWithTrigger
Itoo1.Notification

Please where are the examples (I can not found examples on google)

Thank you

It looks like @Kumaraswamy should update the documentation in the first post...

Use the notification style extension together with itoo to send notifications

Here are 2 examples in the first post

And read the complete itoo thread to find more examples...

This extension is an advanced extension... try the examples and play with the extension to get a better understanding how it works...

Taifun

1 Like

Hi
I'm trying to find a simple working example of a background task to understand how it's working but I can't find any. I read all the threads about that subject but they are all at least 1 y old and most of the blocks are deprecated.

Is there an updated version of the extension ? I feel that if things change so fast then even if I get something to work it might not a few months after.

I'm trying to make mqtt receiver work in the background and set an alarm if need. The alarm extension works fine when the app is in the foreground but need to be able to set it when the app runs in the background.

Thanks in advance

You only have to read this thread from the beginning to the end to find several examples...

The latest version of an extension yoi always can find in the first post

Staet with something simple and get that working first and if you got stuck, show us a screenshot of your relevant blocks

Taifun

Hi! I have the same issue with the following error message: No such service ComponentInfo{edu.mit.appinventor.aicompanion3/xyz.kumaraswamy.itoo.ItooJobService}

I tried using both the emulator and building the app and testing on my phone (in which case there is no message but nothing happens). My blocks are attached.

Essentially this just waits and checks if all data is received from tinywebdb before proceeding. I never received the message from the notifier implying the block is never executed, am I missing something or applying this incorrectly? For reference I had messages with similar notifiers in other blocks as well and the messages were displayed without any issue. Thanks!

I managed to run the example posted here [FREE] Background Tasks: Itoo - #352 by aeozyalcin so then I tried to modify my blocks.

I can't connect to mqtt. I could use some help. I share only the important blocks sorry for the small appearance I couldn't find how to share only a part of my blocks.

In the background there is no user interface... so the notifier will not work, try the notification style extension instead

Also you always have to test using the apk file

Taifun

In the background there is no user interface... you are using textboxes and image components... this will not work

Try the notification style extension

Taifun

1 Like

What I want to do is start my app normally with all the interface blocks and catch the event when the app is closed or sent to the background or the mobile does to doze mode, then start the background process (blocks with the Itoo extension)

Is that the correct approach ? Or do I have to connect via Itoo extension blocks from the beginning even if the app is in the foreground ?

The connection changed procedure is missing few arguments.

Also the mqtt received procedure should use exactly the same argument names as its corresponding event

Taifun

1 Like

I would appreciate the help, I already updated my project to this latest version, but my problem persists and it is the following, the process works very well for me in the foreground or in the background but when I lock my phone it no longer works, this happens on some phones and in others not, there is a way to prevent the service from stopping working with the mobile phone locked?

I updated the variables like you said but still can't connect to mqtt.
So my question remains. The blocks that are used for the interface can cause the code to malfunction? I need them when I start the app. After I close the app or send it to the background I need the mqtt still receiving in the background

It is unfortunately completely dependent on the model and the manufacturer.
This problem does not exist on Stock Android, rather custom skins of Android manufacturers use.

For improvement, you can disable any battery optimization (Android 10>)
There isnt really much you can do about it.

Google had promised to enforce Android standards, such that the behavior across all the devices are uniformed, but this promise has not been fulfilled.

It may also help if you post your relavent blocks of the project.

As said before, you cannot use UI components in background AT ALL. In background process there is NO UI, therefore you cannot perform such actions.

In the meantime, for testing, you can use Notifications extension to debug and report information:


If you are really interested in reporting the changes directly to the user via user interface, then you would need to use broadcasting communication methods added in the latest version of the extension.

May help:

Please take a look at the following.
The "clock2.Timer" event runs smoothly. I get the random numbers on the notifications but the "UrsPahoMqttClient1.MessageReceived" doesn't run in the background like it should. It's working fine when the app is open but not when it is closed.

Could this be a limitation of the UrsPahoMqttClient extension ?