Can you use macrodroid to start an app in its service mode

FrameXX

Well-known member
Give a specific example. This way it's not clear what exactly do you mean. Being pesimistic I can tell you that MacroDroid has next to no control over services of other apps, unless you are rooted and can execute some shell commands. The best I can think of is MacroDroid launching the desired app and then launching home screen, which could initiate some of the app's background services if it has any.
 

Endercraft

Moderator (& bug finder :D)
The send intent action supports sending to a service but I don't think apps support it unless it's made to be controlled by other apps for example.
 

Wjbell1

Member
Well here's what I'm trying to do. I'm trying to use macrodroid to start macrodroid every hour. I know it sounds ridiculous because it is ridiculous. For some weird reason macrodroid shuts down out of the blue. I have looked at my logcat, tried disabling certain things through ADB... It's stupid and I just chalk it up for this phone being stupid. So I need to work around that fires off a new instance of microdroid to try and keep it running. I can do this by starting a new instance of the app, but the only problem is it pops up a brand new instance of the app which interrupts what I'm doing. Now I could use the UI interface from accessibility to push the back button or something. But, for some reason on this phone when I enable the UI interface accessibility option it breaks other things like the sending sms location deal I had about a week ago. So that's what I'm doing if it's too much trouble I'll just scrap the idea and tell I get a new phone that may or may not have these issues.
 

Jacob L

Moderator (Lawsonator)
Follow steps at dontkillmyapp.com. Also see the Github for dontkillmyapp.com as there are suggestions.there on fixes.
 

Wjbell1

Member
Follow steps at dontkillmyapp.com. Also see the Github for dontkillmyapp.com as there are suggestions.there on fixes.
Been there done that. Don't kill my app.com isn't anything special it just details the steps that anybody would probably get into their system and find out anyway. Nothing magical there. Thanks though.
 

Wjbell1

Member
If MacroDroid is forcefully closed in the background you should try setting it as device administrator app. That may or may not help.
Thank you. I tried that also. It doesn't help. I know it's probably my phone that's just a POS... But at the same time I've noticed through multiple phones that macrodroid isn't a very good program when it comes to things being thrown at it that it's not used to dealing with, for lack of a better way to put it. Definitely not a program I would call mature or robust.
 
Last edited:

Endercraft

Moderator (& bug finder :D)
Thank you. I tried that also. It doesn't help. I know it's probably my phone that's just a POS... But at the same time I've noticed through multiple phones that macrodroid isn't a very good program when it comes to things being thrown at it that it's not used to dealing with, for lack of a better way to put it. Definitely not a program I would call mature or robust.
MacroDroid has pretty much everything to ask the system "keep me alive and relaunch me ASAP if you kill me" so it's really your phone wanting you to not lose battery.
If you can't disable these optimizations you'll need root or another phone.
 

Wjbell1

Member
MacroDroid has pretty much everything to ask the system "keep me alive and relaunch me ASAP if you kill me" so it's really your phone wanting you to not lose battery.
If you can't disable these optimizations you'll need root or another phone.
All battery optimizations that I have available to me in the system UI are disabled. If there was anything available to me through ADB I'd gladly try it. I'd root it in a second if it wasn't my only phone. But I have macrodroid running as high priority as I can...
 

Wjbell1

Member
MacroDroid has pretty much everything to ask the system "keep me alive and relaunch me ASAP if you kill me" so it's really your phone wanting you to not lose battery.
If you can't disable these optimizations you'll need root or another phone.
And another thing, there's no relaunch. Period. If there's a checkbox in settings of macrodroid that said if under any circumstances macrodroid is not running (verify this every second I will take the performance hit) restart me ASAP! It's a user choice and a smart piece of code for macrodroids reliability... And for a program that's meant to continually run so we can run tasks on the machine... Am I wrong on this? That's the first thing I would do as a programmer. I've written thousands of lines of code myself. Perl, mind you, but complex code running home automation tasks. So I have an idea of what programmers are working with. Just put in the code!! Above All Else keep macrodroid running even if you have to start a whole new process and a whole new part of the memory system whatever I'm not THAT into programming. But you get what I mean.
 
Last edited:

sampleuserhere

Active member
And another thing, there's no relaunch. Period. If there's a checkbox in settings of macrodroid that said if under any circumstances macrodroid is not running (verify this every second I will take the performance hit) restart me ASAP! It's a user choice and a smart piece of code for macrodroids reliability... And for a program that's meant to continually run so we can run tasks on the machine... Am I wrong on this? That's the first thing I would do as a programmer. I've written thousands of lines of code myself. Perl, mind you, but complex code running home automation tasks. So I have an idea of what programmers are working with. Just put in the code!! Above All Else keep macrodroid running even if you have to start a whole new process and a whole new part of the memory system whatever I'm not THAT into programming. But you get what I mean.

Nah, It should be the OS's responsibility if the app fails to restart after the app is getting killed. As long you set autostart property on for Macrodroid, the OS should restart Macrodroid as soon as possible. You could test this behaviour by force-stopping Macrodroid through App Info. If the OS does its job properly, it should revive Macrodroid several seconds later.

The property also can't be set by the app themselves, it should be done by the user manually for any 3rd party app. IIRC those policy was deployed since A6 or A7, so those are old stuff. You can confirm everything online or just straight ask ChatGPT instead.


Anyway, you may want to change your approach. Find out who is the actual killer first, then take of care them.

You can run adb shell dumpsys activity exit-info *macrodroid package name* from adb to find out who is responsible for killing Macrodroid.
 

Qarboz

Well-known member
And another thing, there's no relaunch. Period. If there's a checkbox in settings of macrodroid that said if under any circumstances macrodroid is not running (verify this every second I will take the performance hit) restart me ASAP! It's a user choice and a smart piece of code for macrodroids reliability... And for a program that's meant to continually run so we can run tasks on the machine... Am I wrong on this? That's the first thing I would do as a programmer. I've written thousands of lines of code myself. Perl, mind you, but complex code running home automation tasks. So I have an idea of what programmers are working with. Just put in the code!! Above All Else keep macrodroid running even if you have to start a whole new process and a whole new part of the memory system whatever I'm not THAT into programming. But you get what I mean.
I'm not a software developer, but I think if the app was killed (it doesn't run!) it can't relaunch itself, maybe...
 

Endercraft

Moderator (& bug finder :D)
The property also can't be set by the app themselves, it should be done by the user manually for any 3rd party app
From what I remember there are both. There are flags MacroDroid has to try and stay in background and autostart which can be effective for most device but sometimes for example with Xiaomi you need to set the autostart permission yourself (although the app won't launch unless it has a flag to autostart).
But some OS just don't care apparently. I know Samsung is rated worst in app killing but at least you can prevent this. If you can't even do that then... Does the phone even pass the Android test or whatever ? It must pass it to have access to Google play store..
 

sampleuserhere

Active member
From what I remember there are both. There are flags MacroDroid has to try and stay in background and autostart which can be effective for most device

Those two are different, his question was about why Macrodroid didn't start itself, while it was more likely the OS that didn't kickstart Macrodroid.

You were probably talking about this doc when you were referring to staying in background. https://developer.android.com/about/versions/oreo/background

It's still relevant to his problem though since his Macrodroid was shot down first, probably it's just another OEM trying to make sure their phone runs smoother.
 

Endercraft

Moderator (& bug finder :D)
MacroDroid should also stay alive as it runs as a foreground service (unless you hide the permanent notification I believe).

Ultimately it's @MacroDroidDev who knows what the app does exactly.
 

Wjbell1

Member
Well I appreciate the replies. And I will try to track down what's killing it with that ADB code above. At first I looked at the logcat and found out that something in accessibility with talk something or other was killing it. So I disabled that through ADB and now something else is killing it
 

FrameXX

Well-known member
macrodroid isn't a very good program

You just touched my prayer, my sweetheart, my darling, my heartthrob. You will be torn apart into thousands of pieces :mad::confused:😏🤣🤣🤣. I partially agree. I mainly suffer from inconsistencies both in UI and logic, but it's also important to note that MacroDroid in its base is over a 10-year-old program. You may imagine how problematic can it sometimes be to maintain program with such old "core", which also explains why many times many developers choose to start from scratch or remake the whole thing. I am really throwing words around, as I myself don't have any extensive experience, but just wanted to point this out.

Jamie will hate me.
 
Last edited:
Top