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

It always would help very much to explain, what exactly does not work

My blocks are not required

  1. you do not use full screen intents
  2. you ask already for post notification permission in the Screen Initialize event
  3. you do not use an alarmmanager and therefore you do not have to ask for exact alarm permission

Taifun

1 Like

shake and sms location and give a call.i have a working .aia for this.I want it to run in background.Can u please do it for me?
i am ready to pay.
here is nirbhaya.aia

nirbhaya.aia (87.1 KB)

Hi, I have messaged you privately.

I've been struggling with this extension since morning. I realized one thing, the extension is not stable for some reason. Sometimes it works great, sometimes it stops working altogether. I don't understand anything anymore

there is no difference, I tried that too

Which means, you are at the very beginning of experimenting with this beautiful extension

I'm working with the extension since several months and can't confirm that

What about finding out, what's going on? Use logcat! Capturing Device Logs using adb logcat

You also can log something from the background there, just use the Notifier.LogInfo method for this

Screenshot_20241014_143344_DuckDuckGo

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 .

In your latest screenshot you are still using the 3 alarmmanager methods... I already explained twice, that these are obsolete...

also are you sure, that the gottext event handler gets triggered in the background? This was my recommendation earlier

Debugging helps...

Taifun

1 Like

Hi @Kumaraswamy,

Any news with the NotificationStyle ?

Hi @Jimis, I'm very sorry, a lot of pending works.
Hopefully I should get some time to work on the issue this saturday.

Hello Kumaraswamy,

Question:
Can Itoo.StoreProperty / Itoo.FetchProperty be used to store and retrieve an "instant" such as is returned by Clock.Now?

Problem:
I have a test case (which I can provide, if necessary).

Within Screen1.Initialize I set a global using Clock.Now.

And I display it on a label using Clock.FormatTime - no problem.

I also use Itoo.StoreProperty to store the value from the global variable. But when I use Clock.FormatTime on the value returned from Itoo.FetchProperty, I get a FormatTime argument error.

When I compare the two representations of instant (the global variable and the result of FetchProperty), they show equal.

A further comparison, character by character, also demonstrates their "equality".

Have I played "fast and loose" with appinventor typing?

Kind regards,
Randal

TinyDB can't store instants and my guess is, itoo also can't do it.... the stored instant looks like an instant, but is not an instant anymore

Store millis instead

Taifun

1 Like

Ha! Nice work of art.

So although it "looks" like an instant, it is only the "image" of an instant :slight_smile: ... as it is said: "looks can be deceiving"

Thanks for jumping in with the explanation and solution! I'll use millis and convert to instant when needed (e.g., FormatTime)

BTW, I ran into this when converting an exiting app to use the itoo services and therefore moving all globals to itoo store/fetch memory... So far, this is the only incompatibility that I have found. Are you aware of other object/types which can be retained in globals but which cannot be stored/fetched from TinyDB or itoo memory?

Kind regards,
Randal

1 Like

what does this error mean? for some reason only 4 out of 5 signals are triggered 1,2,4,5 3 signal never triggers. the blocks are identical. and maybe this information is useful to someone, when clearing the cache of the application or phone, background processes are disabled, you need to start the application again.

I think, instants are the only one
Taifun

What is a signal?
To find out what is going on, check your blocks and logcat...

are you using several itoo instances in parallel at the same time? Don't do this! Have you been duplicating blocks from your previous screenshot?

  • You cannot run more than one foreground or background service.

Taifun

Excuse me for asking too much, but without your help I cannot solve my problems. I am grateful to everyone who helped me. (I read the documentation

, can I turn on switcht On - True in the background? or click on the button?
since we can set the clock timer (green block), but for some reason this method with switch does not work for me
123

You may use the hidden Itoo feature.

Change Swtch110n => ui_Swtch110n, it will redirect the procedure call to UI if active.

DO NOT perform any background operation in that procedure.

I am looking forward to implementing these great new 4.4.0 features/behaviors! Before I do, I have a few questions as to their use/abuse :slight_smile: .

I am converting an existing app to use an itoo background process/service and have decisions to make as to how to modify and/or break it up into code that runs in the foreground vs background. The following questions may seem strange, but I think they will help me minimize the changes. I apologize if the are too obtuse :frowning:

  1. May itoo.CallBackgroundProcedure be done FROM the background itself and execute normally?

  2. Similarly, can a ui_<procedure_name> be called from the UI itself and execute normally?

Or in both cases (1 & 2) one must use "InBackground" to determine the calling context and avoid this?

[the following concern nesting of these new call mechanisms]

  1. If the UI calls procedure X using CallBackgroundProcedure what is returned if X calls InBackground? Further (if permitted), if X then calls procedure ui_Y, if ui_Y calls InBackground, what does it return T or F?

  2. Similarly if ui_Z is called from the background, and if ui_Z calls InBackground what is returned? Then (if permitted), if ui_Z calls procedure A using CallBackgroundProcedure, what would InBackground return if called from A?

Again I apologize if these questions do not make sense.

Kind regards,
Randal

The CallBackgroundProcedure is only meant to be called from the user interface (non background), it wont have any effect if you do so from background.


Yes! The naming convention ui_ just tells Itoo that the procedure must be executed on the user interface. (Note: if the application isnt active, the procedure wont get executed). You can also normally use the ui_ procedure.


It will be true since now you are in the background.


Now it will return false, since the flow is not in the background anymore.


It is the same as when X called ui_Y, it will be false.


Now again the application flow is in background, so it will be true!

Thanks for very clear answers! It all sounds very manageable.

Only one more question occurs to me at this point: Is there a call that the itoo background process can make to determine if the UI is active?

-Randal

Hmm maybe there are such features offered by Android, but with the current version you cannot do it directly.

You can create your own methods, for e.g. you can implement any of these:

  • Heartbeat timer: Update a value every X second in UI and check the last updated time in the background.
  • Echo method: Send a message from Background -> UI, and make the UI send back a response to the message. If the background receives response in given time, then it concludes the UI is active / inactive.

You may expect this feature officially added in the upcoming updates.

Kumaraswamy,

Thanks for the information... and two great ideas if it is necessary. But as I understand it, making the mistake of calling ui_xxxxxx from itoo background would not do anything (and therefore, not anything bad :slight_smile: )

I also intend to use the implicit event registration you have provided in this update - another nice touch!

BTW, may I ask what "itoo" means or represents (a word? an achronym?)

[Edit about 4am GMT Wed]
Came across another question:

How can UI get a function return from a background component. For example, if Player1 is running in a bg itoo service, how can the UI determine the value of Player1.Is_Playing or Player1.Source?

Any method other than the above "echo method" in reverse?: UI procedure X calls bg procedure Y that makes the inquiry (Player1.IsPlaying) and sets an itoo variable which is monitored (loop or alarm) by the UI X for an updated value....?

Randal