Background Tasks [4.0] πŸ₯³

:file_folder: GitHub

Tasks 4.0

β€Žβ€β€β€Ž β€Žβ€β€β€Ž β€Žβ€β€β€Ž β€Žβ€β€β€Ž β€Žβ€β€β€Ž β€Žβ€β€β€Ž β€Žβ€β€β€Ž β€Žβ€β€β€Ž β€Žβ€β€β€Ž β€Žβ€β€β€Ž β€Žβ€β€β€Žβ€β€β€Ž β€Žβ€” Background works simplified


logo

In this version, the complete source code is rewritten to make it better with significantly large improvements. This version lacks some features which were in the previous versions until it gets stable enough. There are a few highlights, which are mentioned below.

Highlights

  • Ability to access app’s procedures.

  • Improved scheduling of tasks and components creation.

  • Application auto-open (experimental).

  • Ability to load templates files into memory.

  • Force restart services option.

  • Enabling task service timeouts.


Docs :open_file_folder:

Explanation of all the available blocks in the extension.


CreateComponent

Creates a component from the name given.

component is the component source package and the name, or a simple name e.g β€œButton” which refers to the button component.

name is the unique Id for the component.



CreateFunction

Creates a function that can be later. When a function is called, the block will be invoked with the arguments provided on the UI thread.

When it’s called, if the return value exists, it’ll be saved to variables.

id is the unique Id for the function.

component is the id of a component that was created to call on.

block is the name of the block or method.

values are the arguments for the block or method call.

Accessing args

You should use {$<arg_number>} to choose an arg that will be in that value. Incase the argument is a non-string object, and you just use the argument, it will be treated as it was.



CallFunction

Calls the function by its Id.

id is the Id of the function that was created



ListenEvent

Listens to an event on the component.

name is the event name.

component is the component Id to listen on

then needs a function Id that will be called when an event raises.



LoadTemplate

experimental

Loads the template from an asset file into memory that can be reused.



ExtraFunction

future deprecation

A type of block that is used when an event is raised.

id is the unique Id for the extra function.

codes are the list of java sentences that will be interpreted.



ConfigureForeground

Configures the foreground notification.

The Id of the notification is 1, so if you want a custom notification then you can just use any notification component with the Id to change that.

A default set of values will be assigned if not called.

title is the title of the notification.

content is the title text.

subtitle is the subtitle text

icon is an icon name for the notification. Go to android docs and pick a small icon name starting with β€œic_” e.g " ic_dialog_alert".



CreateVariable

Creates a variable that can be later accessed later using special texts like {$my_var}.

name is the name of the variable.

value is an object that is the value.



Start

Begins the background service.

id is the unique number of the service.

latency is the delay before the service starts.

requiredNetwork type of network required for the service to run. any, none, cellular, roaming and unmetered are the posible values.

foreground if its a foreground type service.



Cancel

Cancels the service from the Id.

id is the Id number of the service.



IsRunning)

Checks if the service is running from the Id.

id is the Id number of the service.



ActiveIDs

Returns the list of running and pending service Ids.



Exact

Sets the mode the service will begin, if set to true, extension will use alarm manager which is good at schudling exact jobs.



Repeated

Check it to true if you want to the app to restart the service once its stopped.



RepeatedType

If set to β€œHIGH”, the extension will aggresively restart the service manually. β€œHIGH” and β€œDEFAULT” are the two posible values.



TimeOut

The max time in millies the service can run, once the time is reached at a point, it will be killed.



Procedures

Name of procedures that can be called from background.


Extension

Thanks to all the contributors and beta testers.

Extension was created with Rush by @Shreyash.


Download

xyz.kumaraswamy.tasks.aix (464.9 KB)


Known issues

  • Foreground service doesn’t initialize for Android 7 and below [Moderate]
  • Things such as API keys can be exposed in ADB Logs [Critical, fix needed]
  • Crashes on devices Android 5 and 6 devices. [Moderate]

Thanks,
Kumaraswamy :partying_face:

73 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
2 Likes

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!

8 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

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

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

I’ve been testing since Monday :thumbsup:

13 Likes

That’s awesome! Thanks for making video on it!

3 Likes