Background Tasks extension [3.8 A] 🥳

Amazing job!
Congratulations!

5 Likes

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

      ai2.appinventor.mit.edu_ (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.

      ai2.appinventor.mit.edu_ (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.

      ai2.appinventor.mit.edu_ (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.

      ai2.appinventor.mit.edu_ (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 :)

6 Likes

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:

ai2.appinventor.mit.edu_ (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.


SharedScreenshot

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

NotificationTest.aia (406.1 KB)

3 Likes

How may make Repeat function on setTime start and end.

tillTime: what is the time format?
show log
The function may not exist: notifier

1 Like

You remove the ExecuteFunction block. ExecuteFunction should be only used for components on CreateFunction block.

2 Likes

it will only run once, but how to repeat any times ,?)

2 Likes

You use CreateComponent and then use ExecuteFunction.

2 Likes

thank, work, need testing few days)

3 Likes

Let me know if you find any issues or difficulties :wink:

2 Likes

I made a demo project which shows the notification twice in the Background. This can be extended or the times can be changed by increasing the tillTime value:

return String.valueOf(System.currentTimeMillis()).substring(8, 12);

The above code is in the fifth index in the values list. This will be interpreted and we get a random number. This is to show two different notification.

(Tested on Emulator running Android 7 and Android 10 Samsung)

NotificationRepeat1.aia (404.2 KB)

3 Likes

thank you very much

3 Likes

hello iam trying ro learn the extension i made this to show dialog notifire but not working can help me

3 Likes

Welcome, remove this list and set an empty list here. You should only put an index when the value needs to be interpreted. Everything else is fine.

3 Likes

I don't think showing a dialog in the Background will work. I will look into it. The app produces error which is logged. This is the issue with the UI components mostly.

2 Likes

Really after seeing this extension, I can't control myself to don't did nice reply.

2 Likes

Is this working with Kodular also????

1 Like

No, this extension doesn't support Kodular.

2 Likes

Hii @Kumaraswamy Nice extension
I want to run firebase in background and want tag and value after the data changed and show tag and value in notification same as notification from firebase
Is this possibe ?

2 Likes

it is a dream :partying_face:
Wow that is the Best Extension :star_struck: :star_struck: :star_struck:

3 Likes

Currently events are not supported but maybe added later :wink:

1 Like