I have an apk which runs only on background. I want it to start itself every X seconds.
I can do it from terminal with sh command:
#!/bin/bash
while true
do am start --user 0 -a android.intent.action.MAIN -n com.xxxxxxx/.MainActivity
sleep 20
done
But after reboot it stops running itself automatically. Besides, I don't want to use sh command everytime. So I decompiled the apk with apktool. What do I need to add to make our app start it self every x seconds?
p.s. I know that if I save the commands as sh file into etc/init.d/ it'll be persistent but I'm trying to learn how can we add it to source.