Open Source • Background Tasks: Itoo 🚀

Hello Taifun, thank you again for your feedback.
To be honest, my first trials were on my old phone, that runs an older Android version. So, according to your suggestions, I tried again my app on my new phone, that is Android 15 based and that will be the actual device where my app is supposed to eventually run. My app behaviour is the same of the videoclip I posted yesterday, and I have no problem in reading the file, even by background service, since it is created in a directory inside the external storage (file:///storage/emulated/0/my-working-time/provisional-today-times.txt).
Let's instead focus on the actual problem: from my previous picture, I picked up only the most remarkable blocks, that I suspect are concerned in the malfunction:

I already use StopProcess (see picture above) and I don't want modify and overcomplicate an app that is supposed to make a simple operation (by the way, you were previously suggesting me that Broadcast feature was not necessary for my case).
So, my only and actual question is: why I can successfully stop the service in BackgroundMainTimer Event (see red comment "Background service stopped here OK"), but I can't when I push the buttons (see red comments "Background service stopped here does not work")? The operations performed are exactly the same: so, why the effect is not the same?
The only different condition I see is the value of AppGoingToClose? flag (it is set at the end of BackgroundPrvFileTimesGotText Event, it is visible in the bottom of my above picture), that decides if the moment has come to stop the service: when I press the buttons, that flag is still False, but under the logical point of view this should not affect the app behaviour...
I post here aix file of my project:
WorkTimeNotifyService.aia (304.2 KB)

So if you want to stop the background processing, why not only use StopProcess? Trying to additionally stop the clocks is not necessary imho...

After you modified the file outside of your app? I doubt it...

Taifun

Hello Taifun,
I followed your last suggestion, but I see a severe problem concerning the handling of Clock component in background and I can't understand the reason.
I simplified as more as possible my app, by stripping away all the unneeded features, and I included a notifier to show an alert message in the spots when the secondary Clock (BackgroundStopTimer) triggers and when StopProcess procedure is executed.
Then, as you advised, I set to stop straightly the service inside the buttons events, without passing by the secondary Timer.
Apparently, MainClock.TimerEnabled and StopClock.TimerEnabled instructions are effective only inside BackgroundMainTimer event; whenever invoked by buttons or elsewhere, they are totally ignored, so main timer Clock keeps running.
Here the blocks of my debug trial:

And here a videoclip showing the malfunction:

Here below the AIX project file of this debug version:

WorkTimeNotifyService_DEBUG.aia (278.4 KB)

I badly need for help in order to exit such empasse.
Thanks in advance.

Please explain what exactly is not working
What do you expect and what happens instead

Taifun

In the debug version I included the button Set All Times to set the flag AppGoingToClose?, that decides when background service and timers have to stop.
The expected behaviour is that one related to Set All Times button: the timers are properly handled and eventually the clocks and background process are correctly stopped.
On the other hand, when I use the buttons (Stop Work Notify Service in the app interface or Stop Service in the notification), background process and timers do not stop, even though they are expressedly disabled/stopped by StopService procedure. In both case, StopService procedure is invoked (see the alert messages), so why in the latter case process and timers do not shut off?

Do not use the Notifier.ShowAlert method in the background... in the background there is no user interface... for debugging use the Notifier.LogInfo method instead and check logcat

Taifun

Hello Taifun, thank you again for your prompt feedback.
I would to simplify the things even more and I decided to resume my basic example app, that I used as template for the development of my actual app. Here below its blocks and AIA file project:

SimpleItooProject.aia (155.4 KB)

At that time, I tested such app on my old phone, that runs an older Android version (10 or 11) and it was working like a charm. Today, I tested it also on my new phone (Android 15 based) and I see the same exact problem: the disabling operation of the Clock (Clock1.TimerEnabled = False) and/or Itoo.StopProcess operation is ineffective, so the timer keeps triggering in background.
Therefore, it is quite strange that there is a case where my actual app stops background service and timers successfully, since it is supposed to not.
At this point, I am going to suspect that Itoo extension has some inconvenience with the latest Android versions, so it would be nice to get the opinion of Kumaraswamy as well.

Please check logcat for any errors

Taifun

Hello Taifun,
As per your suggestion, both on my old phone and new phone, I generated logcat log file of only Error level messages (adb logcat *:E) with Simple Itoo Project app running:

logcat-simple-itoo-project-old-phone.txt (13.1 KB)

logcat-simple-itoo-project-new-phone.txt (77.7 KB)

While logcatting, the app has been launched, then I started background process, then I closed the app, finally I tried to stop the process by the button on the notification message. On the old phone, process/timer has stopped successfully. On the new phone, as I already told you, process/timer does not stop and the timer keep triggering, so I tried up to 5 times to stop it, but in vain.
I had a look at the logs and I see errors occurring both on old and new phone, but honestly I have no clue how to read and decode these logs.
As usual, any help from your side will be very appreciated.

Hi yes, Stop Process seems to be ineffective on latest version of Android. This needs to be fixed.

Hello, can you help me and tell me why it doesn't work if I want to use the web component in the background?


look these are my blocks and it doesn't work in the background

I tried this way and it works but if I want to use the web component it doesn't work

Could you tell me what I'm doing wrong? Thank you I await your response

Hi, Please read the first post, Principles of design and usage completely

Version 4.4.1

  • Adds an option to set Firebase Bucket (i.e. for ExecuteInternalScript block)
  • Fixes an issue when accessing the Screen component blocks
  • Fixes an issue where StopProcess is being ineffective on Android 15+ devices

xyz.kumaraswamy.itoo.aix (90.9 KB)

Donate: PayPal.Me

Could you please help me, I can't get the web component to work, only the sound works with the notification, I already checked and did the same as the documentation you did but it doesn't work for me.

This is what I need please, I'm going to send you a donation for your great work, but I can't get it to work please

Could you please post your all blocks related to Itoo in high resolution? They are blurry to read.

Look at this example it doesn't work I want to make the web component work


look at this other example if it works perfectly fine

What do you want to do after the Web Request? Play a sound and show a notification? Then you have to register event for Web1.GotText with 4 parameters.

  1. Create a procedure called Web1.GotText with 4 parameters that of the event.
  2. Secondly, use the Melon Notification instead of Notification Style

In fact, I performed the same procedure that you mention but it still does not work, my intention is to activate a sound when executing the web component when I get a response, but it does not work.

Your blocks are wrong...

  1. You cannot use global variables in background
  2. You cannot use TinyDB in background, use Itoo's Store/Fetch property
  3. Why are you attempting to use CreateProcess within the web procedure? It an lead to crash.
1 Like

you are the master of masters
Captura
In this way the data is stored and obtained?

1 Like