nice @Kumaraswamy !!
Extension 3.0 A
-
Re-continued the extension
-
Added event blocks that can call functions.
-
Component support (The extension doesn't let any component like (example: player) kill itself when the app stop or destroy)
-
Foreground support that will let you run apps like a music player!
-
Important: Stabilized much more! The extension supports firebase, other components like clock etc!
Demo blocks
Here, after 5 seconds of latency, we will send a value to the firebase database of value tag text
.
For more tutorials check out my the above blocks (they are 80% the same) after going through Q/A in this post;
The extension is created with Rush and the same for AppInventor, Kodular, etc...
-
Upcoming features
- Possible interaction with the main application from the service.
- Periodic tasks (normal job service) that help you execute tasks frequently.
- JSON input which will allow you to take the input tasks as JSON and execute it.
-
Question: Why we are calling the
Initialize
block of firebase?
It's because the firebase components need to re-initialize this way when we use it this way (dynamically).
It's the same for components like LocationSensor and others as well. -
Question: Why components on UI thread?
It's because components like Firebase, Clock and other components MUST be created on the UI thread to initialize. This thread consumes a little more time to create components than default ASYNC. The extension will wait for the creation of the component as in the earlier(Ai2 thread) some days back issue.
-
Question: Will it work on Android 5?
Yes, it should work, at least most of them. It may be late for the system to create a service but should work; as the test on Android 5.1.1
Hi,
How can i do if statement in event? For example if event value == 2 call function 1 else call function 2.
Is this possible?
Thanks
Currently it's not posible. Will be added in the next update.
ok. Thanks
Extension 3.1 A
The new version is ready and includes the below changes:
-
Extension is now more likely to work with components like Notification style and other things .
It was my mistake actually.. When the Notification style extension has called (.getClassName) while preparing for the start value for the notification, it would be null and it could not function.
-
Added support towards comparing objects/boolean values (true/false) and others like a string when any registered event is raised.
Here is the usage of the new component
ExtraFunction
. It's the same as a function that will compare the texts and if the result is true it will call another function. It basically filters values.Wherever you will use
{$0}
in the Extra function block that means the event values, its the same as the function block which replaces data.For the function to know (differentiate) if the function Id is extra functions or the normal functions, you'll need to add the dollar symbol before that.
To compare strings you should use
"anotherstring".equals("comparingstring")
or the equals segment. To compare numbers or true or false values you will have to use the=
symbol twice like ({$0} == 7
). Suppose the{$0}
is the event value which means7
the extension will replace and will compare it like this7 == 7
and the condition is true so it'll execute the function.After the comparison, put a space and put
::
with the function inside the function Id, then it'll call the function, below is an example of how it works.
0 event value: "77" (this is string and NOT number)
functionId: "show-notification"
"{$0}".equals("77") :: function(show-notification)
"77".equals("77") :: function(show-notification)
true :: function(show-notification)
(now the result is true so it will call the function id 'show-notification')
- Download the extension: com.kumaraswamy.tasks.aix (431.1 KB)
Hello, now you can compare objects
Great. You are the best. Now i can call function when its "true" how can i add else? so when its false it would call a different function.
Thanks
Hello, you can provide two elements to it, so you can prepare different If else statements.
You can add !
exlamation mark at starting at the condition like:
!"{$0}".equals("something")
or
{$0}".equals("something") == false
then it will only execute if the condition is false.
I mean when its true true :: function(show-notification) else function(show-notification2)
so if the statement false i want to call a different function.
Thanks
got you. thanks a lot man. can you dm me your ppal i'd like to donate?
Thank you very much!
But it will not work if you close the app
I think this version of Background Task Extensions is released by @Kumaraswamy
In Kodular Community.
How do we use this? Is there any comprehensive documentation?
Do we put these inside of other blocks in our app, or only standalone?
In the .CreateFunction block, what in the world is the difference between 'ID', 'Name', and 'Function Name'? Also, What are the 'Values'?
If I have a Clock already going, Does this use it? Do I need to create a new clock within one of these blocks somewhere?
I can't wait to get started! I just need literature!
ID
in the function just to call the created function using CallFunction
block. In the background, the extension will prepare things but it's not directly.
Name
refers to the created component's ID here. FunctionName
is the block/function name that you want to call.
Values are like extra inputs. If you don't have any input, you can just provide it with an empty list.
Here, the right side blocks are to create a component and connect to a BLE device.
I am thinking to simplify the names... But this may also brake projects.
Background Tasks 3.2 A
As time passes... The extension gets better and better
So here is another update for it!
There is a total of 3 new blocks, 3 bug fixes and 3 changes!
(Click on the image to expand it.)
-
New blocks
- Clears the task list (the functions/create components) or resets them.
- Returns the list of currently running or pending service IDs list.
- 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.
- Clears the task list (the functions/create components) or resets them.
-
Fixed issues
-
Fixed an issue where if you had entered any function that has Caps in it, the function would be failed to call.
-
Fixed an issue where the service would stop after some time after the app's screen goes off.
-
Now the service will run/start even if the phone is booted or restarted.
-
-
Internal/Blocks changes
-
Finish task block updated with the boolean value to indicate if the service should start again.
-
A new way to call functions and return their invoke or the return values directly. This can be used through the MakeExtra block as (invoke:[FUNCTION_ID])
-
Now the extension does a quick validation of tasks to prevent empty tasks from being sent to the service.
-
Download the new version (3.2 A) com.kumaraswamy.tasks.aix (455.2 KB)
If you find anything wrong, please let me know
The new repository for the extensionβs sources are here
The extension is created with Rush by Shreyash!
Please help me to create an example code. when the phone battery reaches 20% or below, activate an alarm/ play sound. it should work in the background, and also the phone screen is off.