Background Tasks [4.1] 🥳

Hi Van, thanks!

In theory, if it works when the App is opened, it should also work when it’s closed.
Some OEM devices put restrictions on background services causing them to not work properly.

If there is something like the phone’s battery optimization On, turn that off and check for background restrictions put by the device.

See here, how it varies by device:


I don’t have a BTC account now, I have PayPal:

1 Like

I am now working on a thing that makes calling procedures possible from a background (foreground) service :partying_face:

Did a few tests yesterday, got them working :blush:

4 Likes

Do upload it on github also please. :+1:

1 Like

Almost done :partying_face:

Some beta testing and few more tests remaining :grin:

1 Like

You can count with me to help with the tests. Just send me the aix and tell me what you want me to do and I will be glad to help

1 Like

Version 4.0 is launched! :partying_face:

Working with procedures

A guide that explains the use of procedures for downloading a photo from the internet in the foreground mode.

version 4.0



download_photo

We create a procedure that will download a photo from the argument.
Currently, if the app closes, events won’t work except for others.


Initialize

In the event Initialized, we have set the property “Procedures” so that the extension can keep track of the procedures even when the app goes off.


Now we have to create tasks and start them.

CreateComponent

We create a component named #Fun here.
It is an inbuilt component.

Then we create a function with a block named “Invoke”.

It is a function that will call our download procedure.

For the values, we have to give it two inputs, the first one will be the procedure name we are calling and the second element are the args in a form of a list, in which there is an image URL.

When the Procedure is invoked completely, an event of name “Processed” will be called, then the function with component “self” and block “stop” is invoked that will stop the service itself.


Start

The last step is to start the service, we define latency and properties accordingly. foreground should be checked to be true for our procedure to work.

Since our program needs internet, we set “requiredNetwork” to “ANY”.


This logic can be applied to all components and inbuilt blocks (maths, texts…).

Foreground mode needs a notification to stay live. To configure the notification accordingly use the ConfigureForeground block.


Downloads

Blocky.aia (466.9 KB)

Make sure to change the Image URL.

10 Likes

#Fun - where from???
how to use it

@Xoma, show a simple example plz

1 Like

You just have to type that, its an inbuilt component in extension. :wink:

1 Like

@Xoma: “set Tasks1 procedures” - need to use for EACH procedure?

No, you have to give it a list of names.

1 Like

@Xoma, where do these elements come from in “CreateFunction”???:
“end task”
“self”
“exit”

maybe example from standard components from Kodular?

Those are inbuilt. You don’t have to do anything.

1 Like

to be honest, I didn’t understand at all where the “self” component and the “exit” block came from (((

we don 't understand your thoughts ) We need simple examples.

What do you mean? Just they are inbuilt, pre created things (in a simple way). You just mention and use them.

1 Like

ok.
math function?
How use the #Fun component for “math” operation?

Please understand how it works before asking it. You apply the same logic of the procedure.

in examle “Blocky” where is the creation “end task-self-exit”?

@Xoma,
how do I apply a timer or alarm to these called procedures?

or can procedures be called only once?