I'm trying to restart an application (com.android.snapchat) through am
command.
My code to start the application is
am start --user 0 -a android.intent.action.MAIN \
-n com.android.snapchat/.MainActivity
The above starts the snapchat application. However, my program flow is to achieve this:
while true
if(snapchat is running)
then
restart snapchat
...
else
start snapchat
....
How can I do this using am
command itself?
For restarting the app first run
am force-stop com.android.snapchat
and then start it again with the command you've been using.