Background Tasks extension [3.8 A] 🥳

Thank you for the extension Kumaraswamy.

I am testing and trying to learn how to use the tool.

I discovered the example app must be run as a compiled app; not in live development with Companion.

You said

This still seems to be true. The extension cannot be used with blocks that have an Event handler like


LocationChanged( latitude , longitude , altitude , speed )
Indicates that a new location has been detected. Speed is reported in meters/second Other values match their properties.

StatusChanged( provider , status )
Indicates that the status of the location provider service has changed, such as when a provider is lost or a new provider starts being used.

I hope your are able to enable that feature. :slight_smile:

I am testing on a Samsung A10 Tablet using Android 8.1. When I run the example and press Start, it produces an audible note (indicating Tasks is enabled); then it does not appear to do anything. What is supposed to happen? Pressing Stop, quits the Task (the app's icon disappears).
After clicking Button3 (Create component); nothing seems to happen. What am I not understanding?

What causes confusion is the example uses two extensions; your Tasks and the Notification. More explanation would be appreciated. Thanks :slight_smile: When you add more features, this extension should be great.

Perhaps someone who has discovered how to use the extension could please post another example showing how to use the tool?


I came across this extension by @Taifun that can run Location Services in Background
It may not solve your problem completely but surely can help :blush:


@SteveJG This extension does not make it possible to receive real-time alerts or motion detection while running in the background. A → Foreground service is required for this, as is the case with Taifun's Location Service extension.


Thank you for the link Kaustubh! :slight_smile: Taifun's extension works quite well with the LocationChanged Block. The app I built with it continuously records locations while the app screen is asleep, however, the extension is not yet able to provide a Notification while the app screen is asleep. I was hoping Background Tasks could do this. Not yet. :frowning:


Is it possible to call and run a procedure in background?


From the description of the extension:
"A notifier will be displayed while the location service is running in the background."

If you want to display a Notification when the device is in idle (sleep) mode (screen off), you can use my extension:


Hello all, create a component button is used here to save all the tasks which will be executed when the service is started. The InvokeComponent has a parm called time which means the time in milliseconds the function will be invoked. All scheduling is done Asynchronously. That means in the compiled app you will need to click on create the component and then the start service button. Note that the invoke time should not be over or the time given should not be passed to the extension to work (In a simple way you will need to start the service before time is over). If the time is already passed then I extension simply ignores the function not to make the app crash or to stop the service.

I have already made a topic here that to help with the issue but not yet got a reply which solves:

It is possible to make events for a specific component for example a clock. But do not find it possible to make it for all the components created dynamically.

It is possible to keep updating or tracking the user location, just need a block that can directly return the details, this can be repeatedly called until a specific time, delay and interval by using the executeFunction block then saving or uploading the data. But please wait for the next update.


Is it possible to call and run a procedure in background?


I don't find it possible to do it.


Thank you for the explanation. Got it! What was missing was is that is necessary to press Create component prior to Start. :slight_smile:

Certainly. Will follow the development. :grinning: Thank you.


I am happy that my extension is helping people


Congratulations !!!


Thanks my old friend :smiling_face_with_three_hearts:


what tasks can this extension run? background music player? launch notification by date? launching a notification on time?


Kumaraswamy already indicated some components like the Player cannot run in the background in post #21 . He also indicated you can not use it with Event Blocks yet for any components.

Be aware, the extension is still in early stages of development. Have you tried the extension to do any tasks?


no, haven't tried it yet. if the extension can launch the player, notifications by date and time. then eo will be the best extension


I did many tests from yesterday night. There are components like sensors, player and other things which the extension is not properly run it. I tried it with the Clock component and a notifier which shows the Now value or Now block in the clock component after every 700 MS in Background and it just worked fine. (Not possible with the current version, this is tested in the beta version of the extension, note two: tested with property blocks) Looks like sensor components doesn't work properly with extension, just they work when app is alive and the value is not updated anymore. Here you need an alternative like the extension which directly returns the value and it can be called using the extension.


Amazing job!


Version 1.1

There are 3 new function blocks added with the ability to change the notification icon.

  • Call Function

    • Invokes any function which was registered using the CreateFunction block (18)

  • Logs

    • Shows the logs of the extension which will help to locate errors and solving problems. Just the log of the extension will be saved. (19)

  • Save variable

    • Saves the value to a new variable, things like joining text and values can be done. This can be also used to run Java code. The variables can be accessed through saves/<NAME> as saves/MyData. (21)

  • Action Icon

    • Sets the action icon of the notification when the app is running in the background. Notifications for Android versions of 7 and below will not be shown. Refer to this link to find all the icon codes in numbers: Android- Icon codes. (20)

Thanks for the 27 likes which shows how useful the extension is to people :blush:. I have updated the first post with the documentation and new version :)


This example shows how to use the newly added features of the extension.

Our goal

First, when the Screen initializes we will store data with a tag to Tiny DB with the value Hello. Here we need to get the value from the Tiny DB with the tag and store the value somewhere. Then we are going to append the value <space>World. At last, we will be showing it in a notification. To do this we will be doing this: (22)

We will use the InvokeFunction block to get the value from the Tiny DB. If you want to store the result then type the variable name you want to save in the whenResult value. Now will have the value stored when tested. The data can be accessed like [data/<NAME>]. [data/result] in our case as the value is stored to variable result. (Make sure you have created a Tiny DB with the name tiny_db)

After that, we will use Save block to store a new value. Here set the format value to true if you're using ant variable values. [data/result] means Hello here and the plus operator appends the values. So we will use [data/result] + " World!" which will get formated to "hello" + " world" and which finally will be interpreted to Hello World and will be saved in variables as the name of NewResult these values can be accessed through saves/<NAME>. saves/NewResult in our case.

Next using the notification style extension we will create a function called MyFunction and show a simple notification. The notification subtitle will contain the interpreted value which is Hello World. Make sure you mentioned the index in interpretValues list which value you want to interpret.

At last, we will call the function using the CallFunction block.


And here is the result. If you get a blank value then try adjusting the timing.

NotificationTest.aia (406.1 KB)