i want to create app running in background if lux = 5, flashlight goes on automatically.
I hope you should explain it well,
Don’t forget to provide what you have tried so far
true
But let me stop you right there because I want to point out one thing:
If I have the phone in my pocket?
Do sone experiments with itoo
See also some examples…
Taifun
Give it a try and see the result, though its not on same topic
This block structure works fine, but when i minimize the app in background then it doesn’t work.
I also try this but not working
As i said you must store the value of checked, then use it with conditions
{My suggestions}
Call the rest block
I double checked your blocks, you’re setting properties light sensor, the RegisteredEvent should be Light sensor
- with this blocks the app is working fine when app is active.
- but It doesn’t work as soon as I minimize it.
- I just want it to run in the background. How to do that. plz give me block diagram to run in the background (when app is minimized and screen is locked)
If you don’t mind can i take a look in your aia?
Thanks dear for ur support. Now this app also is working in background.
Now I want to add timer like at 8:00 Pm the flashlight automatically turn on and at 9:00 PM turn off (desired time should be manually entered)
This is my project and now working fine in background. I just replace the switch with button
You could do it with itoo and a clock, however this is not recommended because of the following 2 reasons:
-
Usually you do not want a persistent notification being displayed for the user while your background process is running, which is required for itoo
-
Also usually you want to keep battery usage of your device as low as possible… a process running in the background to compare regularly if it is already time to do something drains your battery…
That’s why usually you would use the alarmmanager functionality of the Android operating system to get triggered at the given time. My paid alarmmanager extension would be able to help…
Taifun
Hi Parveen,
Taifun (as always) is absolutely right, but if you still want to proceed, this is one option.
This should work as you asked.
I added two TimePickers and, when they change, we save the data to iToo using StoreProperty.
When the light changes, check if the current time is within the TimePicker range.
I’m not an expert in handling time on Kodular, so I’m not sure if this is the correct method.
I hope someone can correct me if there’s a more efficient way.
LightSensorWrange.aia (111.3 KB)