Cannot make Flow work in background

113 views
Skip to first unread message

Ron Lokey

unread,
Dec 21, 2025, 10:58:03 AM12/21/25
to Automate for Android
Noob to Automate here.  Very basic flow consisting of error trap -> battery level -> publish to MQTT --> delay .> loop back to top.  Running app on cheap Chinese tablet.

Works great when Automate is in foreground.  Publishes battery level every 2 minutes. But when I put my main app in foreground, it seems like Automate flow quits.  I have basically all privileges granted and turned battery saver off.  Read the link I found in other topic on the subject and still no joy.

My guess is Automate is intended to run in background, so I am definitely missing something.

Any help would be appreciated.

Henrik "The Developer" Lindqvist

unread,
Dec 21, 2025, 7:58:05 PM12/21/25
to Automate for Android
Indeed, ensure to disable all "power save" features, see: https://llamalab.com/automate/doc/faq.html#automate_not_running

мJ Zкxy

unread,
Dec 22, 2025, 7:54:25 AM12/22/25
to Automate for Android
Maybe you could post pic of 2 minute timer block here and set Automate notification on if it stay there should work normally.

Ron Lokey

unread,
Dec 22, 2025, 12:01:42 PM12/22/25
to Automate for Android
Figured out how to enable "Display over other apps" on this device for Automate.  Now for some reason the log is showing "java.lang.IllegalStateException: Plug-in failed with result code: 2" error immediately after MQTT Client plug-in.  here is a picture of my flow.  MQTT Client has a solid connection to broker.
Battery Level.png
and the log
flow-7.log

Ron Lokey

unread,
Dec 22, 2025, 12:57:27 PM12/22/25
to Automate for Android

Posting picture of my MQTT Publish

CP10_20251222-114613.png

Ron Lokey

unread,
Dec 22, 2025, 1:41:01 PM12/22/25
to Automate for Android
Got the java plugin error corrected and like I stated, Automate does now have "Display over other apps" enabled, but still have same problem where as soon as another app is loaded, the Automate flow stops working, no more log entries, it just stops.  I have reviewed the recommendations in the link provided but again, no joy.

Anything else to try?

Henrik "The Developer" Lindqvist

unread,
Dec 22, 2025, 1:45:23 PM12/22/25
to Automate for Android
Then the Plug-in action block seems to work correctly, it can start/communicate with the plug-in which respond with "error 2" that's a generic "failed" error.
Diagnosing why it fails is difficult. Enable the "debug logging" option in Automate settings, that will show the communication.
Look at the system log to see if the plug-in telly why it fails, use a "logcat viewing" app, or this flow.

Henrik "The Developer" Lindqvist

unread,
Dec 22, 2025, 1:50:36 PM12/22/25
to Automate for Android
A flow cannot just stop, it's either manually stopped, it fails, or it reach an unconnected, like the NO path on the Battery level block in your flow.
FYI. Your flow is using "polling" which will drain a lot of battery, please read this.

Ron Lokey

unread,
Dec 22, 2025, 4:11:06 PM12/22/25
to Automate for Android
I understand you regarding the polling.  I have it set to 10 seconds only while trying to figure out my problem.  Then I will set it to something like 10 minutes.
Obviously you know the App way better than I do, but when I say it "stops", I am solely basing this on what I see in the log - the log actually stops logging any activity.  To rule out the NO path on the Battery level block, I tied it into the top of the 10 second timer.  When I press START it cycles through every 10 seconds and publishes the Battery Level, but when put another open app in foreground, my flow seems to stop.  I can go back and put Automate in foreground, nothing shows to be logged from the moment I took it out of foreground earlier and the Stop button shows "Stop (1)" like it is still running but nothing new is being logged.  If I press Start, it tells me I cannot have duplicate flows running.  I can press Stop and it will then log "Stopped by user".

Oddly the MQTT Client app does not ask for any Permissions and it functions in background just fine.  What would you think the minimum Permissions would be for my Automate flow?  Is there a better way to get Battery Level published to MQTT broker than the flow that I am doing?

Thank you for taking the time to help me.

Ron Lokey

unread,
Dec 22, 2025, 9:13:24 PM12/22/25
to Automate for Android
Installed same apps on different device, everything works as it should - even with minimal Permissions allowed for Automate (basically the app defaults).  My problem is definitely something to do with my other device.  I will keep chipping away, but don't see a need to burden anyone else at this point.

мJ Zкxy

unread,
Dec 23, 2025, 8:55:40 AM12/23/25
to Automate for Android
Which Android OS you're using this could be timer bug when it stop count when app is closed.

Ron Lokey

unread,
Dec 23, 2025, 10:57:50 AM12/23/25
to Automate for Android
Android 12

Henrik "The Developer" Lindqvist

unread,
Dec 23, 2025, 11:06:36 AM12/23/25
to Automate for Android
Then the flow is likely pausing to await something, looking at the flow log should tell you where.
In your case it's likely a Delay block, since you device seems to have problems running apps in the background. 
Ensure the Delay block is using Proceed=Exact at Awake device=yes, also try using the "Alarm clock" option as "Timer accuracy workaround" in settings, as described in the documentation.

Ron Lokey

unread,
Dec 23, 2025, 8:23:08 PM12/23/25
to Automate for Android
Update:  Have Battery Level flow installed on 3 tablets, working on 2 - one of which is sending level via HTTP request (Android version 5 too old for MQTT Client app) and the other tablet I got running is actually a Chinese tablet very similar to my problem child.  Difference is the Chinese tablet that is working is Android 13 - Go Edition where the one that is giving problems is Android 12 - Go Edition.

I did set the delay block as you suggested, and the "Alarm Clock" option does make the delay blocks much more accurate.  I agree that maybe the flow is not stopping but maybe waiting for something because the last entry I ever see in the log is the delay block entry.  But when I put the Automate flow back in the foreground - the flow appears to be stalled out, it shows to be running but never logs another loop.  Only other thing I noted is that when I started the Battery Level flow on the Android 13 tablet, Automate popped up and said I needed to grant "Notification" privilege - which I did, and then suddenly the "Tablet MQTT" app popped up and stated it also needed "Notification" privilege as well even though it did not require such at install nor after I configured the broker and connected to it.

Ron Lokey

unread,
Dec 24, 2025, 8:14:33 AM12/24/25
to Automate for Android
Appreciate the help, but I am ditching this Android 12 tablet for this application but will be using one of the other tablets that will run Automate correctly.

Right now, I just have 1 flow (Battery Level) that I am using on the 2 devices and working well.  I am sure I will add more flows in time.

Nice App.  Thanks for the help.  

Case closed!

Xyrelle Morallas

unread,
Dec 25, 2025, 9:03:39 AM12/25/25
to automa...@googlegroups.com
Recover

--
You received this message because you are subscribed to the Google Groups "Automate for Android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automate-use...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/automate-user/af64f4fe-e83c-4191-87f6-1712ba5d9517n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages