Background Tasks Extension [3.6A] 🥳

An extension to create components, call functions or tasks in the background and when the app is alive with various features!

Extension version :appinventor: :kodular: → 3.6 A
Last updated: 2021-07-19T18:30:00Z


Beta testers and helpers


@rizu @Maayur
@vknow360 @Mohamed_Tamer @WatermelonIce
@Hrichik_Mazumder @AryanGupta @Know_About_IT @PratushRoy


Documentation

Here are the documentation of all the available blocks. If you have found a mistake then let me know about it. :smile:

  • Creating a component

    03.04.2021_12.15.46_REC

    Creates a component. No matter if the app is running in the background or the foreground. All you need to do is to specify the component source name and the name which will be used to invoke functions and do other stuff.


  • Creating a function

    03.04.2021_12.16.58_REC

    Creates a function of the component ID specified. Specify the component ID and the values. To access the invoked result use the ‘invoke:result’ value to store it in a variable and then access it using the extra value block.


  • Calling a function

    03.04.2021_12.19.38_REC

    Calls the created function using the function ID. Make sure the function of the specified ID is created before using this block.


  • Call a function multiple times

    03.04.2021_12.21.58_REC

    Block to call a function specified number of times with the interval between each call. Make sure the function of the specified ID is created before using this block.


  • Creating a variable

    03.04.2021_12.24.38_REC

    Creates a variable with the specified value and the variable name which you can use on functions.



  • Making a delay

    03.04.2021_12.51.19_REC

    Does a delay in Milliseconds. You can use this block between functions and tasks. This will not affect the UI of the application.

  • Making value from code or text

    This block helps you make value from invoking results, do things. The value from it will be executed at the invoke function.

  • Resolve activity

    03.04.2021_12.57.13_REC

    I strongly recommend using this block. Mostly on Chinese devices which requires additional permission to run tasks in the background.

  • Finish task

    30.06.2021_22.32.16_REC
    This block will report to the Android system that the service and tasks are completed. Gives an advantage by saving the system’s resources. Use true as the parameter if you want to remove the foreground notification.

  • Start the service

    24.06.2021_22.57.00_REC

    The service will be executed with its Id and latency in MS. The required network takes the following input:

    • NONE [DEFAULT]
    • ANY
    • CELLULAR
    • UNMETERED
    • NOT_ROAMING

    If you want your service to be executed in foreground mode then you can check it to true.


  • Configure Foreground

    24.06.2021_22.59.37_REC

    Sets the title, content and subtext for the foreground service.

    Icon codes list: Android - developers

    There will be more methods added soon, like media notification.


  • Cancel the service

    03.04.2021_13.05.22_REC

    Cancels the service by the given service ID.


  • Register for events

    24.06.2021_23.04.17_REC

    Registers the event and calls the function id with the parameters. They can be accessed like {0%}. Index starts from 0.


  • Destroy component

    24.06.2021_23.05.52_REC

    Kills the component at the time in MS and stops all the events.


  • Kill events

    24.06.2021_23.07.02_REC

    Stops all the tasks.


  • Create on UI thread

    24.06.2021_23.07.46_REC

    Creates components on UI. By default, they have created ASYNC. It’s very important to use this block if you’re using the Clock component, firebase and others.


  • Extra function

    26.06.2021_18.05.19_REC

    The extra function is to compare objects and call the respective function Id. To know more about this click here.


  • Get pending tasks IDs

    30.06.2021_21.05.52_REC

    In the format of a list, returns the pending/running tasks IDs


  • Reset task list

    Reset

    Clears the task lists and all the functions (Create components, functions, events) and others.


  • Restart after Kill

    30.06.2021_21.07.29_REC

    When the service is killed, this property block will be to indicate if the service needs to start again. The restart time depends on the System.

  • Periodic tasks

    Periodic tasks will run the service with the given interval with a minimum interval which is 15 minutes (after Android oreo). This functionality cannot be used with latency. Latency should be set to zero.

    17.07.2021_15.56.50_REC


  • Flags feature

    • Flags are to pass any extra values or to change the behaviour of the service. There are currently three flags.

      • FOREGROUND_IMPORTANT Marks the foreground state of the service as important using the internal API.

      • IGNORE_FIRST_PERIODIC_RUN Ignores the first periodic run which gets immediately fired when the service is started. Make sure to stop the service before starting it again if you are using periodic tasks, else it may misbehave.

      • ACTIVITY_NO_KILL The flag is to stop the tasks (like the player) from being killed when the app is alive and the service is being killed.

  • Alarm

    Alarm

    A block to start the service with the exact instant provided. ID is the service Id that will get started when the alarm is fired.

  • Repeating alarm

    18.07.2021_14.24.26_REC

    Sets the repeating alarm for the service with the Id. Time is the instant. Interval is the time between each repeating alarm.

  • Cancel alarm

    18.07.2021_14.26.14_REC

    Cancels the pending/ongoing alarm. Also, cancel the service by CancelTask block.


Know more about internal features here.

Extension

This extension was made possible for all platforms by Rush:

Open source

Download

The extension is free for everyone to use!

Version 3.6 A
Download extension:
com.kumaraswamy.tasks.aix (468.3 KB)

Other version(s)

(1.0)

Download extension (Click) :kodular:

Download extension (Click) Alternative link

Previous version (2.0)

Extension specially for Kodular: com.kumaraswamy.backgroundtasks.aix (377.2 KB)
Alternative dowload: App Inventor Community

3.0 Version

This version works with every platform.


3.1

Bug fixes and improvements

com.kumaraswamy.tasks.aix (431.1 KB)


3.2

Bug fixes and improvements

com.kumaraswamy.tasks.aix (455.2 KB)

3.3

com.kumaraswamy.tasks.aix (452.5 KB)

3.4

com.kumaraswamy.tasks.aix (448.0 KB)

3.5

com.kumaraswamy.tasks.aix (467.4 KB)


About extension

If you’ve found any bugs, issues or something wrong in this post then lemme know about it. Suggestions and improvements are appreciated :smiley:

Thanks,
Kumaraswamy B.G

52 Likes

I am trying To Run Download In background but When I starts the service then my app is stopped

Blocks

BTW, Thanks For The Extension :heart: :heart:

The other extension may not support it. You will need to debug blocks you’re self. Remove some blocks and test again. If it works continue and go on. These hard operations may not work with the extension as of now. (Maybe until next update)

2 Likes

I collect data from my website to my app as shown in this img:

but i want to notify user when ever i change my data that the app receive ( if the app is in background or close ) as shown data is receive in label 2.

Now i want to use a background extension to process the background function and show notification when ever receive data is change.
I am using the free background extension.But no idea how to start and use.
Screenshot_3

How To Set Property Of The Component ?

How to set it with firebase, if firebase value change show notification.

1 Like
1 Like

You should use invoke function block to set or call functions.

First I recommend you to do simple GET request and do some experiments :slightly_smiling_face:

Great extension.

1 Like

Share your aia file I will check it.

1 Like

download_background.aia (627.2 KB)

New update coming soon!

7 Likes

Can I send notification from firebase by running firebase in background
I want onData Change block to run in background and when data changed of firebase db i want to show notification title as tag and message as value

Is it possible with this extension ?

2 Likes

You can use default block added with firebase called when value changed. If not you can use clock timer to check the data for a particular period of time or every second

1 Like

Use the same logic using the web component with events :wink:

But how we will know what should we type in the text…

The extension should be little bit simpl to understand

1 Like

Screenshot_5

We are meaning this block only.If any data changed in firebaseDB immediately this block will get triggered So you have to design remaining blocks what to have to happen

1 Like

Just use the logics, create a component, invoke a component, do things with it’s result using save block and more. I will be posting some examples here soon. By the time you all can go through the posts here:

1 Like