Run the timer in the background The extension has used background tasks 4.0.Discussion is accompanied by blocks and aia file

BTW, for timer why do you need this extension?

Simple web compo, tinydb alone is enough

You can open 50 topics if you want, you still will not be able achieve to run foreground services on Android 5.1.1. Give it up

1 Like

@Still-learning
When the Internet is weak, the time does not
appear from the Internet, so I resorted to this
Or the lack of internet on the phone

@72erdelyi
The owner of the extension in one of the comments (running on Android 5.1.1)

Did you tried to start it?

I can’t see the Task Start activity on your Screen.

I guess I’m stupid for this extension :pensive:

@Ded_Sec_00
Where do I put the activity start block!?

I advise you to do like this.

Get current time
Decide final time and convert into millis…save into tinydb

When screen inti or started timer, get current time(online time) convert into millis, then add +1000.

By using datetool extension you can find the difference between current time with tinydb final time and convert into HH mm ss without internet.

Simple…

Else test this APK

1 Like

So even the app closed, timer will be calculated once he open the app

@Still-learning
My goal is when I press a button the timer works and when I go back to the application and press another button the timer stops, this does not stop.
With that, the same problem (the internet is weak) exists.
I waited 3 minutes to reopen the application.
Because the Internet is very weak in my area, I need to do that without the Internet at all.
Thank you for your interest in helping me

Since there was / is no Doze mode on Android 5.x, it is sufficient to set TimerAlwaysFires = true. As long as the app is not closed, it should work on Android < 6 (API < 23, Doze mode was introduced with Android 6).

Note: Whether the timer works in the background (app not visible, in idle / sleep mode) has nothing to do with a BackgroundTask, but depends on whether Doze mode is active or not.

@bodymindpower
My goal is for the timer to run in a mode (sleep, idle, when the app is paused) not when the app is closed. When the application is closed I don’t want it to run (temporary)

Can this be done without changing any programming in the extension?

Read my answer again. Everything to this has been said.

@bodymindpower
Ah, sorry for my stupidity​:sweat_smile::sweat_smile::joy:
I understand now .
I will try it now

I dont open community as much as I did before :eyes:


Here is a simple thing which you can apply in the blocks:

  • CreateComponent == component = Clock, “clock”
  • CreateFunction == id = “set interval”, component = “clock component”, block = “TimerInterval”, values = Give a intetval in a number.
  • ListenEvent == name = “Timer”, whenEvent = “do something here!”, component = “clock”
1 Like

Thank you, I will do what you told :heart::heart:
@Xoma

1 Like

@Xoma
excuse me .
Can you take a look at the aia file above and correct me?
Thanks​:heartbeat::heartbeat::two_hearts:

please give me this extension or example aia

it looks like you are using MIT App Inventor…
therefore please ask there in this thread Open Source • Background Tasks: Itoo 🚀 - Extensions - MIT App Inventor Community and do not forget to ask your question… I only can see some blocks…

Taifun
PS: I’m closing the 2 year old thread…

1 Like