Open Source • Background Tasks: Itoo 🚀

🧩 Itoo 4.4.2 Sky

:octopus: Github :gift_heart: Donate

BuildWithLove forthebadge


An efficiently designed virtual background execution environment for App Inventor.
Powered by the ItooX framework.

It allows you to run blocks in background the same way you do normally when the app is active.

:star2: Please go through all the details and documentation listed below before you try to use the extension or seek help from others. Efforts have been made to be precise and simple at the same time.

You need to be familiar with App Inventor to use this extension. Difficulty level being Medium-High.


📚 Terminology

It is essential to understand basic terms used in this documentation and in this extension.

  1. Background: When we use the word "background", we may refer to two things.

    • We say "the app is running in the background" – we mean that some operation is being done while the app is not active.
    • The second meaning, we also refer to "background" as in "background service" as opposed to a "foreground service".
  2. Foreground: Just like the word "background", this word has two meanings.

    • We say the app is in "foreground" – meaning the app is open, being active.
    • The second meaning, we refer to "foreground" as in "foreground service" feature offered by the extension.

🛠️ Types of Service

A service is basically something that runs also while the app is not open or when the app is closed.

  1. Background Service: A non-visible background work that can be scheduled using Itoo.

    • Runs silently without user noticing it.

    • Vulnerable to being stopped by the system abruptly, can only run upto a few minutes in modern devices depending on the phone brand, OEM, OS installed, etc. (also see dontkillmyapp.com)

  2. Foreground Service: A user visible and recommended way to execute something in the background.

    • Itoo is primarily based on supporting this service.

    • Generally can work non stop for ever, but could be limited to a few days or less time depending on the phone brand you use.

    • A permanent notification is shown while this service is active starting from Android 8 (Oreo).


📝 Principles of design and usage

To run blocks in the background, you code the blocks normally then use Itoo to execute them.
There are a few things you need to follow while you are using Itoo:

Usage

  • Before you try to do something with Itoo, first get it working normally.
  • Do not use global variables, or try to access/set them.
  • Do not use user interface components such as Label, TextBox or even Notifier since there is no interface in background.
  • You cannot use Tiny DB, alternatively you are supposed to make use of the similar storage features Store/Fetch property blocks offered by this extension.
  • For the main background procedure, you need to include an argument "x".
  • You cannot use normal Event blocks in background, use RegisterEvent block to listen to component events.
  • You cannot run more than one foreground or background service.
  • A component does not get created until you touch any of its block.

Design Solutions

  • How do you report the status live from background onto the user interface?

    • For that purpose, Itoo offers way to communicate back and forth between the user-interface and the background execution using Broadcasting feature.
  • When a new type of block is added to App Inventor, will be be supported?

    • Yes, but it may not be immediately supported, it would need an update.
  • When the device restarts, how do I start a background process?

    • This can be done using SaveProcessForBoot feature offered by the extension.
  • How do I run a background process 24/7 without any interruption?

    • This can be achieved using a Foreground Service (with CreateProcess) block, but do note that some device brand may abruptly stop anything.
  • How do I customize the foreground service notification?


📑 Documentation


CreateProcess

  • Starts a foreground service, with procedure being the initial point.
    Title & Subtitle refers to content of the Notification.

CreateTask

  • Starts a background service, latency being the delay, with procedure being the initial point.
    JobId refers to a unique service Id to check status and stop the task.

SaveProcessForBoot

  • Useful when you want to start a foreground service when the device boots up.

RegisterEvent

  • Remember, you cannot normally use the Yellow event blocks in background.
    Using this, you supply an event name such as Clock1.Timer where Clock1 is the component and Timer is the event name.

    So what happens when that event is raised? The procedure given will be called with the same number of values as the Event.


Process Running

  • Returns true if a foreground process is currently active.

IsRunning

  • Returns true if the given JobId is currently active.

StopProcess

  • Stops any foreground process currently running.
    Can be called both from background or while the app is active.

StoreProperty

FetchProperty

  • Since TinyDB cannot be used in background due to synchronization issues, Itoo offers a similar set of blocks to serve the same functionality.

  • Captures the green property blocks and saves their values.
    Then in the background, you can reapply the properties.

  • Releases the captured properties of the component. In background.

  • There is only a few specific cases where you might use this block.
    You can use it to initialise a Firebase or a Cloud DB.

  • A way to receive messages from app to a background process.
    Name is the message's tag you want to listen to. After message is received, the supplied procedure is called with an argument i.e the message.

  • Unregisters a registered broadcast in background.

Broadcast

  • When you want to send a message to background or vice versa.

component_method

  • Once a background service has been started, you can use this Block to call procedures in the background.

  • Any messages sent from background will be received here.

InBackground

  • Returns true if called inside a background process.

  • Customize the permanent notification icon.
Possible notification icons

ic_btn_speak_now
ic_delete
ic_dialog_alert
ic_dialog_dialer
ic_dialog_email
ic_dialog_info
ic_dialog_map
ic_input_add
ic_input_delete
ic_input_get
ic_lock_idle_alarm
ic_lock_idle_charging
ic_lock_idle_lock
ic_lock_idle_low_battery
ic_lock_lock
ic_lock_power_off
ic_lock_silent_mode
ic_lock_silent_mode_off
ic_media_ff
ic_media_next
ic_media_pause
ic_media_play
ic_media_previous
ic_media_rew
ic_menu_add
ic_menu_agenda
ic_menu_always_landscape_portrait
ic_menu_call
ic_menu_camera
ic_menu_close_clear_cancel
ic_menu_compass
ic_menu_crop
ic_menu_day
ic_menu_delete
ic_menu_directions
ic_menu_edit
ic_menu_gallery
ic_menu_help
ic_menu_info_details
ic_menu_manage
ic_menu_mapmode
ic_menu_month
ic_menu_more
ic_menu_my_calendar
ic_menu_mylocation
ic_menu_myplaces
ic_menu_preferences
ic_menu_recent_history
ic_menu_report_image
ic_menu_revert
ic_menu_rotate
ic_menu_save
ic_menu_search
ic_menu_send
ic_menu_set_as
ic_menu_share
ic_menu_slideshow
ic_menu_sort_alphabetically
ic_menu_sort_by_size
ic_menu_today
ic_menu_upload
ic_menu_upload_you_tube
ic_menu_view
ic_menu_week
ic_menu_zoom
ic_notification_clear_all
ic_notification_overlay
ic_partial_secure
ic_popup_disk_full
ic_popup_reminder
ic_popup_sync
ic_search_category_default
ic_secure


  • Specify the foreground service type as required by latest versions of Android. DataSync is the default value. You may also specify it in the designer tab.
Service types

Camera,
ConnectedDevice,
DataSync,
Health,
Location,
MediaPlayback,
MediaProcessing,
MediaProjection,
Microphone,
PhoneCall,
RemoteMessaging,
ShortService,
SpecialUse,
SystemExempted (you wouldnt need to use this one)


  • Enabled by default, produces essential debug logcat to trace errors.
    Note: However in the production mode, you should turn it off to not leak any sensitive data in log.

📚 Resources & Quick Start

Some sample projects that might help you start.
Project files are attached at the end, try to copy rather than simply opening the AIA.

Doing a GET request every 5 seconds

CloudDB with Itoo, update data every few seconds

Here is where the ExecuteInternalScript action comes into play!
Code number 2 represents Cloud DB.

Updates Cloud DB every 5 seconds using Clock.
You just need to change the credentials in the values and you can start using it.

Firebase with Itoo, update data every few seconds

Similarly to CloudDB, we use the ExecuteInternalScript with code 1 to configure firebase.
Writes to Firebase DB every 5 seconds using Clock.

Update your Firebase URL Token & start using it.

Capturing and releasing properties for quick setup

Sometimes you have a lot of configuration in the designer property set and would want to avoid setting them manually again in blocks. The Capture and Release property functions got you!

image

You can basically save the state of the properties by Itoo and can be reapplied to the component in background.

This works most of the time, but there might be exceptions.

The above example demonstrates how properties Sensitivity and Minimum Interval for the Accelerometer Component is saved and reapplied in the background.


New features in Itoo Sky 4.4.0

  • Ability — Call background procedures from UI
    Once a background service is started, you can call a procedure to run in background.


  • Ability — Call UI procedures from background.
    Now you can call to update user interface while in background, if your app is open :wink:
    Wait, what are the requirements?

    Carefully notice the above blocks.
    We are registering the Timer event of Clock1 and we keep track of the counts and increment it by 1 each time the Clock1_Timer is called.
    Then we call the procedure ui_update from the background that will update the count in the label.
    So whenever you need to call a procedure to user interface, the procedure name must start with prefix ui_.

  • Ability — Automatic event resolution system
    Beginning from this update, you do not necessarily need to register for events using the RegisterEvent block. From now, Itoo will try to search for a procedure using the naming convention ComponentName_EventName and call the procedure if it exists.

    image

    Demonstrating automatic event registration for Timer event of Clock1.

  • Behavior — Now when you click the notification, by default it opens the application. (Screen1)


More examples:

Turn off device specific battery optimizations: dontkillmyapp.com

Extensions Featuring Itoo(x)


🔗 Extension

This extension can be freely used, including in appathon.

Both extension and framework are open sourced under the GNU-3 license.

By default, the extension does not ask for notification permission.
Use the AskForPermission block or enable it manually.

V4.4.2 xyz.kumaraswamy.itoo.aix (92.2 KB)

:star2: I'm an high school student. This is not an easy extension to maintain. Only possible with incredible hardwork and months of research for perfection put into it.

Please consider donating: PayPal.Me

Project files

All of the project files listed below uses version 4.1. Please upgrade if you target Android 14+ onwards.

SimpleItooProject.aia (81.9 KB)
SimpleItooCloudDB.aia (82.2 KB)
ItooFirebaseDB.aia (82.1 KB)
PropertyCapture.aia (81.9 KB)


Thank you
Kumaraswamy B G

51 Likes
Notification Listener (powered by itoox-wrapper) and Itoo
Itoo X Framework: Virtual App Inventor environment for Background execution
Background Tasks extension [3.8 A] 🥳
Battery checker reminding you to unplug when fully charged
[PAID] :round_pushpin: Location Service Extension
🔔 MelonNotification • Various styled notifications + Itoo
Can I use the background?
Ping a web server every 10 minute
Help with Time duration
How do you use timerpicker for firebase to start/stop specific task?
[Free] :ear: PhoneStateListener extension
Text to speech component in Background
Is it possible to make an app that notifies me with alarm sound when I get new mail from specicific email id?
How can we I get and compare the values of 2 tags in my database when firebase data changes?
Notifications and background activity
Schedule fix desired time to control servo motor
Background foreground
How do I use MIT app inventor's background task extension which helps the app to run in background?
How do I run this app in background?
Background Operation Issue with App Inventor
Keep the app open in the background
Is there a way to do a task when an app is placed in the background?
Need some help with building an app that uses clocks and notifications
Run app in background, that fires an alarm whenever phone is shaking
Fire event when 3rd party app opened?
I am trying to read a string from a web page and compared the string.
📱 How to capture start and end times of a phone call and calculate total call duration
Check if value in cloud DB changed while app is NOT running and create push notification?
Keep the screen on
Background processing
How do I fix “There Was a Problem Parsing the Package”?
[PAID] :round_pushpin: Location Service Extension
How do you launch an app, close it and then come back to mine?
Is it possible that My application generates a push-notification while closed
Automatic call app
Maintain the activity of an application in the background
Test low battery, advise by voice
How do I use MIT app inventor's background task extension which helps the app to run in background?
Экстренная отправка SMS на три номера! (Emergency SMS sending to three numbers!)
Notifications and background activity
[PAID] :alarm_clock: Alarm Manager Extension with Notification or Autostart
How do you run app in background when phone is turned on?
Flash light on call and message
Is it possible to make an app that notifies me with alarm sound when I get new mail from specicific email id?
Play sound when the mic is opened or closed
Need help in making app
App that uses your location and does something in the background with it
Background Service - MIT APP -Help
Background task
Itoo X Framework: Virtual App Inventor environment for Background execution
App Keep alive always
Notifications and background activity
Maintain the activity of an application in the background
Running in Background and as Widget
[PAID] :alarm_clock: Alarm Manager Extension with Notification or Autostart
Alert notification from esp 32 even the app is closed
Send notifications when app is closed
Alert notification from esp 32 even the app is closed
Экстренная отправка SMS на три номера! (Emergency SMS sending to three numbers!)
Entire App Running In Background (or Foreground)
Notifications and background activity
Svegliare la mia app (Wake up my app when it receives an SMS message)
Apps using Itoo and build after august 17 cause the app to crash
Background play of an Bluetooth alarm clock app
Alarm Manager with Itoo
Can't make Itoo extension working
Run Background Notification even if App Is closed by user
To ensure the application works even when the screen is off
To ensure the application works even when the screen is off
Output the reminder in text not only the sound, or in a recorded reminder with the sound
On close / destroy / end / exit or some like this event
Question about background tasks extension
Listening to Bluetooth, and Fetching/Sending Text Messages in the background
Apps using Itoo and build after august 17 cause the app to crash
MQTT extension by Ulrich needs sdk 34 update
Show notifications in the notification shade, running in the background
How do you stop app refreshes or restarts when the screen goes off?
Detailed guide for creating a background music player with #Itoo
[FREE] Pedometer with Foreground Service
How do you detect incoming messages in background?
Notifications while outside app
App crashing, no infinite loop
ClearClipboard - Clipboard Management
Trying to make a multicounter with a different sound at each 60 second mark
Acelerometro en segundo plano
App crashing, no infinite loop
How to use itoo backend to update web page information in real time
Aplicacion en segundo plano
How do I get a notification sound in your Google Sheet when App Inventor app sends text?
Make my app run in the background to play a sound after shaking
Trying to record audio in the background, File1 delete problem
How do you read MQTT data using a background service while main app is closed?
Action conditioned on received Bluetooth data
:eye: itoo Push Notification Examples for ALL!
:eye: itoo Push Notification Examples for ALL!
Is there a free alternative to the Alarm Manager Extension?
Monitoring a Firebase Node in the Background with iToo and Notifications
Clock sensor does not fire when screen times out and turns off
How do you receive and send SMS in the background?
How do I run apps in background?
[PAID] :alarm_clock: Alarm Manager Extension with Notification or Autostart
AudioExoPlayer a simple player with great potential
Invio notifica da app
Background events
Background events
Background activity by a phone shake
Background activity by a phone shake
Pop up notification triggered by bluetooth received data
ContactPicker was fine now fails to return
How do you receive a sms? (using ITOO / in the background)
How do you receive a sms? (using ITOO / in the background)
FMP -> Find My Phone!
Automatic Logout Timer Keep Running
[PAID] :alarm_clock: Alarm Manager Extension with Notification or Autostart
Background notificaton
Background notificaton
About foreground service in an android app
Listening to Bluetooth, and Fetching/Sending Text Messages in the background
How can I activate clock in the background when exiting the application?
Script running when app is closed
Timer Going Off When App Starting
Aplicacion en segundo plano
How do you make app run in the background on minimize?
Automation with mit app inventor
Alarms within cryptocurrency app
How app can control on notification via webview component
Schedule an action
I need my app to receive bluetooth even if the phone is locked
I need my app to receive bluetooth even if the phone is locked
Battery checker reminding you to unplug when fully charged
Screens or Components
Background Tasks extension [3.8 A] 🥳
Notifications pour application de chat
Can you tell how to use task extension to make screen run in background.
Application visible
Permission to switch off "remove permissions if app is unused"
Using LINUX commands in App Inventor. Extension
🔔 MelonNotification • Various styled notifications + Itoo
Page turner and locked screen
Pedometer didn't work in the background
Keep screen on taifun tools
RTE on Parsing a Json and calling if a bool value is true
Keep the app open in the background
Vertical position recording
Player - Device Audio, Loop - Play Streaming
How do I run this app in background?
How can I have my app read the phone orientation in the background
Que llegue una notificación si necesidad de aplastar ningún boton (Let a notification arrive if you need to press any button)
Alarm control application
Making a background app to rickroll people
Menu or icons working over other apps?
Taifun camera usage with locked screen
Taifun camera usage with locked screen
How do you make an countdown app always running?
Extension: Modified Notification Style to support Android 12 and above
How could i use foreground services
Phone falling detection
App just in Notifications visible sending remote media button keystrokes
Need help sending notifications in the background over bluetooth
How can I keep sending SMS to specific time, even when device is in standby-mode?
Background music
[PAID] :round_pushpin: Location Service Extension
Alarm is no longer working after closing and re open it again
Maintain the activity of an application in the background

Awesome work @Kumaraswamy :+1:t2::+1:t2:

6 Likes

Great extension Thank you so much @Kumaraswamy

so by using this extension i can run a procedure on phone boot starts up ?

4 Likes

Did you read this?

5 Likes

Hi, am I missing something in my blocks?

I have just checked Developer Options --> Running Services and this background service is not listed there. I have make not optimized of Battery also.

1 Like

You have to drag atleast a dummy Texting component into the monitorSMS before you call the "When" block.

Thank you Kumaraswamy. I did that but no luck. would you like to look into my aia once?
DSOMonitor.aia (29.4 KB)

4 Likes

Hello,
good morning,
I have a problem,
I have made the program, and it works to send a notification in the background, but after a few hours, it stops working.
I have tested it on two mobiles: Motorola and Samsung.
I attach my blocks in case I left something.

image

Thank you very much for your help.

1 Like

Yes, there are two ways to solve it, completely disable the battery optimization of the app in the app settings and turn of phone battery optimization.

The other way uses a foreground service, i will soon release an update (in a week)

2 Likes

Ok, thanks

2 Likes

Unfortunately, the video is not displayed with either Firefox or Chrome.

2 Likes

But for example, how WhatsApp does to receive messages (in the background) without showing any foreground?

1 Like

They are whitelisted by the device manufacturer and they use the tools provided by the Google like GCM/FCM which are more reliable.

2 Likes

Oh
Thanks :grin:

2 Likes

not wok for me

1 Like

Share your hardware version and your relevant blocks.

blocks
my block i'm using android 10.

2 Likes

No, you cant show AlertNotice or any kind of UI from background.

So how work on boot please show an example.

1 Like

I have to yet update the extension framework, it has not been updated since months.

1 Like