i have send the aia
thank you
Extension Guide and Q/A
These are some of the points that you have to know to correctly use the extension.
-
ExtraFunction
-
FinishTask
- FinishTask block (above) is called in the background/foreground service. This is like a task to be done in the service and not called from outside.
-
Intrepert and MakeExtra
- You will find two blocks that can interpret the Java statements and return the result. Interpret block just directly returns the value (outside service) and MakeExtra will return the value (not interpret result) that will be executed in the service.
-
MakeDelay
- Block will freeze or put the service into sleep mode for the given number of seconds. This will also pause any ongoing operations. This block has no effect on the UI of the application.
-
CreateComponentsOnUi
- If this property block is set to true, components will be created on the normal thread of the application. Most of the components like Firebase, clock, pedometer, Bluetooth must be created on the UI thread. Creating on this thread will need more time for the components to be created.
-
How to work with foreground
- Foreground is mostly used for components like the player or other components to continuously stream from the service. From Android 7 and above, there will be a notification of the set configurations (i.e title, subtitle…)
-
Making it easy
-
It really makes confusing while using the extension when you just have too many blocks. What you can do is split the blocks into procedures like for configuring the component properties, and for functions and registering events.
-
Make it understandable for others to understand: Name the functions and components names wisely. Dont make mess, use short explanatory names.
-
-
Problem starting the service when app closes
-
Some manufacturers try limit the functionality if not has an additional permission(s) like auto-start in especially Redmi phones. This is to prevent apps consuming a lot of battery running in the background. When the phone’s battery optimization is turned on, the system will just not allow the app to start a service.
This is where
ResolveActivity
block comes to play. It will automatically check for the conditions that are needed to start the service.The block opens the system settings to ask for the permission (ignore battery optimization or auto-start)
When/to restart(ing) service, the system decides if to really do it…
If you are using foreground service, then it is just okay to goon without any of the above points needed.
-
-
Stopping the service
-
You should use
self
as component value andexit-foreground
for function name to stop the foreground state. Else just useexit
function name to close the full service. You can given them a boolean parameter (to remove the notification in close foreground and to restart the service for just close service).To close it from outside, use
CancelTask
function.
-
Let me know if anything is wrong
@eagle_vision I just checked the project file which you sent me. There was a small mistake making it not work…
I got it working. It was a problem in the ExtraFunction block. You had put val2.contains("working")
instead of val3
When you get event from web, the counting starts from 0
. ExtraFunction had val2
which is responseType
in the event value. Thus making extension check response type instead of response content. Everything else is just correct
Above is the correct block. Just change val2
to val3
and it will be fine
youpiiiiiiiiii you are the best
How can I make a donation?
PS: As the extension is open source I suggest you to add the open source tag in it.
Hi Sara, you have put the function name for “Source” as “Sourse”. The function name is invalid thus extension will ignore the function. Also, you are trying to start the player every 3 seconds…? What is that for?
Edit: Please update the extension to 3.3 (latest release) if your using 3.0.
Thank you very much! You can donate me via Paypal
Can we create/destroy component in background? to save resources??
Yeah, else just stop the service. Extension will automatically do it for you.
If I need to send notification every morning. How can I stop and restart service?
You can use the latency block (but it will be long).
Then restart the service by functions but you’ll not have a delay.
Will add a periodic block for doing things every interval (recommend day).
I decided to use
compare using extra funtion
Interpret code to get current time
then fire every 45s
I should see how that works now
Also, beware of background restrictions (especially in high-end Samsung and Redmi devices.)
How can we solve that problem? If there was some method to warn users it would be great.
I am not really sure about it.
Samsung has restrictions like if battery saver is enabled it would not work and samsung after android 8+ update also kills the foreground service (have tested it). But its not the same with Redmi.
Redmi/Xiomie devices need auto-start permission just and everything will be fine. Just they dont kill foreground services. But there maybe more restrictions.
You can use the resolve activity block. It will ask for the permission needs to run the app.
Thank you for that. I will test and tell you.
ExtraFunction block is just to handle events.
You should move the compare code to a function with MakeExtra block and the code parm to true.
And at last, what is your goal?
show notification every day at timer picked time.