Background Tasks extension [3.8 A] 🥳

HI,
Below I have attached a screenshot and complete code in aia format.
This code is working and alarm function is working when screen is on.
For testing purpose i used if condition (battery level >= slider position ). i can use phone charger to test the changes in battery level.(what i mean is charging the phone is faster than discharging , finally i will change the if condition from >= to <=
i don't know how to use the background task modules and what values to give. this code is not working in background mode kindly help

BatteryAlarm.aia (618.5 KB)

1 Like

Hi, you are using the very out-dated version of the extension.

Also, you cannot use TaifunBattery.Level as the function name. That would just return the current level.
Finally, everything has to be done through the extension. Everything means setting the clock interval, timer interval and all.

2 Likes

ok, thanks which is the latest version. is it 3.2A?

3 Likes

Version 3.3 A

This version is just bug fixes and improvements :wink:

  • Fixed bug where compare objects in ExtraFunction which had special characters that need to be escaped but were not and it failed with an Exception in the log cat.

  • Changes to the way of accessing the event values with the ExtraFunction block.

    Now the event values should be accessed as val<parameter_index> in the codes element. Everything is just the same.


  • Improvement is done internally i.e optimizing the code, less code.

Download extension
Fun fact: This version of the extension decreased size by over 2 KB :face_with_hand_over_mouth:

3 Likes

good job thanks for your effort I would like you to help me use this extension for my radio streaming. I was reviewing and there is a paid extension for the value of 25 USD but my budget is very low thanks in advance for your help :blush:

2 Likes

KUMARASWAMY_B.G Would you be so kind to republish the blocks please with the new extension if possible I would appreciate it a lot.

I need this code because at the moment my app is working sending notifications every 10 seconds and the truth consumes a lot of battery

Greetings and hugs from Ecuador

Sorry, I dont understand you?

Can you publish the blocks to play foreground using your new extension.

Thanks

1 Like

Hi all, is there any suggestions about the extension?

Improve it to make it easy with fewer blocks or any other way you would recommend for creating functions, components else any better way of doing things..?

Hi How Can i Add An if to the app, like : if Time is 14:35 than send notification.
Greate Work!
Tapps

i see you already answered Thanks!

Yes, you can just set convert the time to to remaining milli seconds and pass it as the latency of the start service parameter. :slight_smile:

Background Tasks 3.4 A

Another exciting update is here with features and bug fixes! :grin:
There may be a few bugs in the release, if you find them, let me know :sweat_smile:

  • Periodic tasks

    • Wanted to run a task every interval? The periodic task is the choice! :upside_down_face:

      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_19.17.37_REC


  • Boot listener

    • The extension already has the ability to start the service automatically if the phone is booted. But the booth even was not possible. This update adds functionality to start a service when the phone is rebooted or switched on.

    17.07.2021_19.21.08_REC

    If you set the Id to "777" while using the above block, the tasks will be saved and be executed when the boot is completed.


  • Multiple events

    • In the previous versions, the extension would just use the listen to the last registered event. Using multiple events on it was not possible. This is now fixed.

  • 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.


  • Change event values

    • Now you can change the invoke values before sending it to any function if you are using the ExtraFunction block to handle events.

      For this, you will need to have a basic knowledge of Java. The same can be done to variables from now on. They will be changed when the result is true.


  • Deprecation

    • The block CreateComponentOnUi is now deprecated. All the components will be created on the UI thread from now on.

Download extension: com.kumaraswamy.tasks.aix (464.9 KB)

1 Like

Great update!

1 Like

Background Tasks 3.5 A

Feature request

  • 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

    Screenshot 2021-07-18 at 14-51-04 MIT App Inventor

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

  • Cancel alarm

    Screenshot 2021-07-18 at 14-51-04 MIT App Inventor

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


Demo blocks

Blocks to show a notification with alarm blocks.

The blocks are the same for App Inventor


Download extension: com.kumaraswamy.tasks.aix (467.4 KB)

2 Likes

ask the question,sorry
I want to use notifier in background
but it doesn't work
Here is my block code
Please help me

Hi, please update to the new version of the extension. It will not be needed to use the CreateComponentsOnUi block.

Resolve activity block is to ask for special permissions needed and it does not start the service. You are not starting it, so it doesn't run.

Also, the component "time" is redundant.

OK thank you for your reply,I remove the clock and resolve activity block,but it still not work,here is my current blocks

,if I lost any blocks please teach me how to finish it,thank you very much

1 Like

Screenshot 2021-07-20 at 09-33-49 MIT App Inventor

Use this block. You are not starting the service.
Latency is set to 5000 ms.

It works pretty good,thank you answers me the question。thank you for your work

1 Like