Open Source β€’ Background Tasks: Itoo πŸš€

I'm on mobile, so I can't check your aia file
If you want help from me, then provide a screenshot of your relevant blocks
Taifun

help please did everything as iknow of but still the clouddb store value is not functioning but if i replace with file1 savefile block the file is updated correctly

you registered the Clock1.Timer event and the File1.GotText event
and you use CloudDB.StoreValue block, this looks fine
later when you start your app again you theoretically should find some value in the CloudDB

where does that file come from?

I now prepared an example for you


Bgtest1.aia (70.7 KB)

unfortunately storing a value in CloudDB gives an error, see logcat output here

so the CloudDB properties have to be set in the blocks for Itoo to work...
unfortunately this is not possible with the CloudDB component, you only can set it in the designer... so it looks like you currently cannot use it together with Itoo... use another database instead...

Taifun

Thanks for the logs... Taifun...

Components like CloudDB and Firebase require some additional initialization invocations done to be ready for use in the background.

Itoo yet does not manually intervene in this matter at the stage of component creation.


Once I get time, I'll do my research to extend the capabilities... yet locked....

Thank you all kuwaraswamy for this awesome ext
And taifun for enlighten the day
Then waiting for the next stage perhaps​:face_with_hand_over_mouth::face_with_hand_over_mouth::face_with_hand_over_mouth:

where does that file come from?

I store the data using another app with capabilty background cuz mit location sensor cant do live data stream in background

You probably have missed my locationservice extension

I'm currently working on implementing itoo functionality...

Taifun

Can i have a test of your extension. just to make sure your ext can send live to clouddb in my phone, Before buying full version

No you can't... the sane restrictions also apply for my extension...
In case ther iis a method, which uses the web component to connect to CloudDB, then it would be possible...

Taifun

In the meantime i think i can do store property in list method and fetch the data when app is alive that is possible right.
Or broadcast block.
Its not live data.:pleading_face::pleading_face:

I need help tracking down a timing/out-of-sync problem that I have illustrated via the attached simplified case [please ignore certain text that would apply to the app that it was derived from :frowning: ]

Here is the aia and blocks (sorry blocks are so small, I used blocks editor save as image option):

DataMinder_ButtonCase.aia (903.1 KB)

The troublesome behavior centers around the NotificationStyle1.ActionNotification with 3 user response buttons and the button response event NotificationStyle1.CallbackButtonAction, which is registered (from 'run') with itoo.RegisterEvent and procedure NotifyStyleCbButtonProcessing.

Initially the Clock.Timer event TimerInterval is 20 sec (20000). When the app starts and "Start" is touched, about 20 secs later the Timer event processing issues the following notification showing the time issued and the value of the TimerInterval (ignore the text that follows):

The user is presented with a choice:

  1. "Half" - Halving the TimerInterval
  2. "Double" - Doubling the TimerInterval or
  3. "20000" - Setting the TimerInterval to 20000.

If "Half" is selected two or three times (reducing the interval to 5000 or 2500), and then "Double" is selected the same number of times, the TimerInterval does not return to 20000.

Evidently I have done something(s) that does not assure synchronous behavior.

This is mitigated (perhaps solved?) by the introduction of Notifier1.loginfo messages which are "disabled" in the blocks.

What have I done? not done?

Kind regards,
Randal

Debug your logic using Logcat. To find possible errors of your blocks in the background, let me suggest to filter the logcat output for the tags, Notifier , ItooCreator and System.err

Taifun

I think I have done about all I can to sort this one. I may have one more idea in me :-), but I am not hopeful :frowning:

Below find the updated the test case code and blocks image.

I have also included an annotated logcat output filtered on several character strings grep -e %%% -e TimerInterval -e Notifi -e System.err -e CallbackButtonAction .

The notations in the logcat files (included below) trace the following behavior:

  1. App "Start" pressed
  2. "> adb logcat" begun
  3. Timer fires after initial "Start" interval of 20 secs (reschedules for 20 secs)
  4. User selects Notification "Half" (next inerval = 10 secs)
  5. Timer fires after another 20 secs (reschedules for 10 secs)
  6. User selects Notification "Half" (next interval = 5 secs)
  7. Timer fires after 10 secs (reschedules for 5 secs)
  8. [no user input to Notification]
  9. Timer fires after 5 secs (reschedules for 5 secs)
  10. [no user input to Notification]
  11. Timer fires after 5 secs (reschedules for 5 secs)
  12. User selects Notification "Double" (next interval = 10 secs)
  13. [With no further user input, within ~30 ms Calback processing executes doubling the interval twice (10s ecs x 2 x 2 = 40 secs)
  14. Timer fires after 5 secs (reschedules for 40 secs)
  15. App "Stop"
  16. adb.exe logcat - stopped

See attached -hidden.pdf file.
DataMinder-wlogs3_20240210-%TimerNotSysCallonly-hidden.pdf (82.4 KB)

To see intermediate/additional filtered logcat entries, see un-hidden rows via:
DataMinder-wlogs3_20240210-%TimerNotSysCallonly.pdf (97.7 KB)

Unfiltered logcat entries are hare:
DataMinder-wlogs3-51-53.txt (71.2 KB)

What I cannot fathom is #13, above: why does the ButtonCallback execute two additional times when there is/was no further user input to the NotificationAction window.

It is as if, when no user input was made (items #8 and #10) that these CallBack "events" were held and then were executed immediately after the expected one (#12), with the last user selected action Button (Double) being used. I have tried many ways to cancel the NotificationAlerts that were "stale" not responded to (see blocks). But they seem to stick around and then mis-behave.

Any help would be appreciated,
-Randal

DataMinder_ButtonCase.aia (903.6 KB)

I would advise you to not use the CallBackButtonAction feature for now, we are not sure how it behaves in the background.

@Randal_Andress

PS: I'm sorry I'm preparing for my exams right now and cannot reply you.

What would be the "normal" way to communicate a change in parameters to a background process that requires periodic user input ?

The blocks below show what I did that seems to avoid the multiple-queuing of unwanted Button-actions. Note the use of itoo1 database item "ActionNotificationQueued" as a flag in the notification sending procedure (LargeIconNotificationWithOptions), and in the button callback processing procedure (NotityStyleCbButtonProcessing) .

It allows only one outstanding notification to be "queued" (flag set by b/g timer processing). If it does not get cleared before the next periodic cycle (via ButtonCallback processing) , the notification is canceled, and the flag is cleared. Then on the following periodic cycle a new notification is issued.

Since I do not understand how all this works :slight_smile: I suppose this may not be bullet proof. But I am hoping that by allowing an entire period/cycle to pass with no new outstanding notification, there will be time for any CallBack processing already started to complete, awaiting the next cycle.

Another approach (that I have not tried) is to post the same notification for user input when the b/g process is started, setting the "queued" flag. Then use Notifer (not reliable?) and SimpleToast to periodically notify the user when input is suggested (e.g., "Stop sending these notices for 2 hours!!").

At any point the user could navigate to the notification that was posted on Start and supply what is needed. This would be processed by ButtonCallback clearing the flag when done. The next periodic cycle that detects a cleared flag would post another notification and set the flag.

Thanks for any comments and help you might offer, kind regards,
Randal

Thanks for the message and I wish you very good success on exams!!!
:student:
-Randal

1 Like

Hi Randal, rather than the explanation (what you have done so far), it would also help to know what you are trying to do so far.

Also since I assume you are touching the callback button features of the notification style component, it's not guaranteed to work in the background (that's why dont use it for now).

I'll be able to take a look into this thoroughly next month.

Hello Kumaraswamy,

I know you are especially busy, so thanks for the reply.

You asked:

what you are trying to do

I want to periodically check the data transport mechanism. If it is cellular, I want to notify the user and give him the opportunity to increase the time between checks or to stop checking ("snooze the app") for a certain period of time. This could help those without unlimited data plans to be more aware of their data use.

I want it to start when the phone is started.

Eventually, I want the user to be able to set various parameters that determine 1) how frequently to be notified, 2) for what reason (under what conditions) to be notified besides simply that data is in use, and 2) how to be notified (a notification, toast, notifier, other?).

Again, I wish you good success in your academic achievements and upcoming exams.

πŸŽ“

Randal

1 Like

You could have the user do this kind of configuration before starting the background service and store these choices using the StoreProperty method. Like this you do not have to use the CallBackButtonAction feature

Taifun

Hi Taufun,

Thanks for helping me think through this one.

I am thinking about your suggestion, which is a good one. Except I do not think I can design a configurable set of parameters that would be sufficient without requiring user input in real time.

The main challenge is different (even changing) user circumstance, preference, and intent. In one instance, the user might be intentionally using cell data for what he anticipates to be a very short time and does not want to forget to turn it off when he resumes watching his movie or listening to his "tunes" which he "thinks" are downloaded onto his phone... so for that situation, he would not want to "snooze" the monitor but be willing to put up with repeated reminders (a minute or two apart).

In another instance, the user may intend to use cell data for an extended period since he realizes he may not be near wifi for hours...so he would want to "snooze" the monitor for those number of hours (or hour by hour until wifi is available - which the monitor could communicate).

Another example is whether or not to include a sound in the notice - preference might vary depending on the circumstance.

I suppose, when the user wanted to make these changes in monitor "parameters", he could simply restart the app, make changes, and then close it (without stopping the b/g task)... this might work well enough. Perhaps this is what you had in mind.

In an earlier approach, I experimented with your alarmmanager facility. Frankly, I forget what problems I ran into (perhaps of my own making and ignorance), but the itoo background approach seemed more of a fit - until I started using the NotificationStyle callback events :slight_smile:

BTW, is there a proper way to communicate reliably between the user and a background task?

Thanks for your thoughts and suggestions,
Randal

Notification Style extension's callbacks just isnt able to properly work in background. I'll write a new notifications extension if possible next month.

You mean live communication or communication by constantly reading/writing? Both are possible.

Check the RegisterBroadcast, Broadcast, UnregisterBroadcast blocks for live communication or FetchProperty and StoreProperty for storing/retrieving data.