Open Source • Background Tasks: Itoo 🚀

It looks like I can't explain clearly which is the problem and there is something that dodges my understanding. My bad.
The log file I posted should be examined in relation to the videoclip of my app running. In the log file, when the device is locked and the screen is marked as off in the log, this can actually correspond to two status that can't be told apart: when the screen is on and when the screen is off. Here is my problem.
We have therefore these 3 conditions:

Device unlocked --> IdleMode.IsScreenOff = False ---> The notification triggers: OK, as expected
Device locked, screen OFF --> IdleMode.IsScreenOff = True ---> The notification doesn't trigger: OK, as expected
Device locked, screen ON --> IdleMode.IsScreenOff = True (but should be False!) ---> The notification doesn't trigger: Wrong behaviour

If the device is locked, but the screen is on, I want the notification triggers, but this does not occur because Anke's extension detects the case "Device locked, screen ON" as IdleMode.IsScreenOff = True.
To show the problem, I modified the debug version of my app by changing the log messages text and by adding a button Log Debug within the notification message itself and I pressed it to record a log message just only when the device is locked with screen active:

This is the corresponding logcat (on each line, I reported the actual status of the device):

03-08 21:32:46.593 30319 30319 I Notifier: DEBUG: IdleMode.IsScreenOff = FALSE ---> Device unlocked
03-08 21:32:51.631 30319 30319 I Notifier: DEBUG: IdleMode.IsScreenOff = FALSE ---> Device unlocked
03-08 21:32:56.649 30319 30319 I Notifier: DEBUG: IdleMode.IsScreenOff = FALSE ---> Device unlocked
03-08 21:32:59.296 18275 2501 I NearbySharing: Screen is locked
03-08 21:33:01.658 30319 30319 I Notifier: DEBUG: IdleMode.IsScreenOff = TRUE ---> Device locked, screen off
03-08 21:33:06.671 30319 30319 I Notifier: DEBUG: IdleMode.IsScreenOff = TRUE ---> Device locked, screen off
03-08 21:33:11.691 30319 30319 I Notifier: DEBUG: IdleMode.IsScreenOff = TRUE ---> Device locked, screen on
03-08 21:33:14.314 31115 31115 I Notifier: DEBUG: Device now LOCKED with screen ON. ---> Here I pressed the button Log Debug in the notification...
03-08 21:33:16.705 30319 30319 I Notifier: DEBUG: IdleMode.IsScreenOff = TRUE ---> Device locked, screen on
03-08 21:33:18.900 18275 30940 I NearbySharing: Screen is unlocked
03-08 21:33:21.745 30319 30319 I Notifier: DEBUG: IdleMode.IsScreenOff = FALSE ---> Device unlocked
03-08 21:33:26.766 30319 30319 I Notifier: DEBUG: IdleMode.IsScreenOff = FALSE ---> Device unlocked
03-08 21:33:28.704 31115 31115 I Notifier: DEBUG: IdleMode.IsScreenOff = FALSE ---> Device unlocked

At this point, I wonder about Anke's extension purpose: does it detect if the screen is on/off, or does it detect if the device is locked/unlocked?
I believe what I really need is something to just detect is the screen is on or off...

Thanks again and I apologize for my miscommunication.

Probably this is what you are looking for

you could write your own extension and create the functionality yourself...

more information about how to create an extension see the App Inventor Extensions document

however that will be more advanced and will require some Java skills...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

I feel like I am a step away from solving such issue and get my app finally working, but the things are getting more and more complicated... :exploding_head: :sweat:
Do you deem feasible to somehow exploit ActivityStarter component to do that?
By the way, just right now I was unsuccessfully trying something like that (I get permission denied and the activity is not found):

Time to go to bed...
Thank you, Taifun.

No
You will have to

Taifun

ITOO extension doesnt works


I need that my APP work uninterruptedly and them I download the ITOO extension. I read the information and I made a very simple example , see the picture, but it doesn't work, somebody could help me?
thanks

You only can register existing events like Clock1.Timer... checkPacients does not exist

And if you want to post something, it might be a good idea to register the Web1 GotText event to find out the response content of what you posted

First get it running in the foreground, then try to get it running in the background

Taifun

Thank Taifun, I fix it but still not working, I show you the complete test I'm try to work (with comnnets)



you can very well debug your code, just use the Notifier.LogInfo method to log something and use logcat to check

unknown

add a ClockPermissions.Enabled to true to start the clock
also you forgot the argument x for the procedure

move those two blocks into your controle procedure


and use only Post OR Get and not both at the same time

unknown3

the NotificationStyle extension is outdated, use the MelonNotification instead

Taifun

1 Like

which start mode are you using for the alarmmanager extensoin?

if you use "Only Notification" you only need Post Notification permission, see again the documentation App Inventor Extensions: Alarm Manager | Pura Vida Apps

if you want to schedule exact alarms, then ask additionally for Schedule Exact Alarm permission

unknown

Taifun

Thank you once more Taifun,

I really don't know why I must put an argument x and if it is really needed what I define as argument X ("...also you forgot the argument x for the procedure..."), for instance : I have to put "response content" due I´m asking a url conexion??

About my start mode, I need an exactly alarm schedule, as you see I already asking for this permission

Because without that it will not work
Read post 1 how to use itoo

???

Taifun

I did not tell you to add an argument responseContent, I said

Your getphp procedure is the event handler for the Timer event. Both the event and event handler do not have any argument, fetchMessage is the event handler for the GotText event. Both have 4 arguments.

What about

As you are trying to call the alarmmanager extension from the background, you first have to set the start mode in your main background procedure console

Also it would make sense to register the Alarmmanager1.Started event to find out, if the alarm time could have been set correctly or if an error ocurred.

Again: use logcat for debugging

Taifun

1 Like

can someone help why is this not working

i have tested the whole web1 code seperately and ik that it can store the value, there r no battery ristrictions currently active on my Nothing Phone 1(that i know of).

Pls help

Hello @THUNDER_THUMBS

Please post an higher resolution of your screenshots the next time. It's hard to read and makes it difficult for us to help you.

I see a few mistakes in your blocks.

  1. Do not use TinyDB in background due to sync issues, instead use Itoo's own StoreProperty and Fetch property blocks. (Read Principles of Design and Usage) in the first post.

  2. Secondly, global variables do not work in the background. They are not defined when you access them from background. So the URL variable must not be accessed from the background.

thank you soo much, i will make sure to send the photos properly next time

1 Like


i have refined ze code, imma try and tll ya later

You are still using TinyDB in the background
Also why do you use TinyDB and Store/FetchProperty methods for the same tags? Just use only Store/FetchPropetty methods to simplify your blocks

Taifun

1 Like

because i am accessing the data from tiny db in other screens too

i saw that error i left in some tinyDB blocks lol, thanks