Search code examples
androidshelltimeoutadb

Terminate process after some time in ADB shell


I am running an app from ADB shell like this:

adb shell am start -n mypackage/.MainActivity

I need to terminate the app automatically after 10 seconds and start another application. I am trying to do something like this:

adb shell timeout -t 10 am start -n mypackage/.MainActivity

But unfortunately this does not work.

Output:

/system/bin/sh: timeout not found

Is there any way to make this work?


Solution

  • Use following

    start adb shell am start -n mypackage1/.MainActivity
    timout /t 10
    kill  mypackage1
    start adb shell am start -n mypackage2/.MainActivity
    

    More Info here