user2044367
user2044367

Reputation: 41

How do I tell if an android activity is finished from an external adb command?

In our testing, I want to use a script to run a number of android activities. I can use an adb shell start activity command to start these activities. Is there a way, using an adb command, to tell when an activity finishes? The script needs to know when the first activity is done before issuing the next adb start activity command.

Upvotes: 4

Views: 4326

Answers (2)

chatlow
chatlow

Reputation: 91

I did something recently where I wanted a bash script to run an adb command and show/wait until it was finished. This is what worked for me:

./adb shell am start -W -n com.android.settings/.ApplicationSettings

The script then waited for the applications menu to load before continuing. Not sure how this would work for a longer process but it's worth a shot.

Upvotes: 4

Alex P.
Alex P.

Reputation: 31676

If you can control the source of the applications you are monitoring, do what Daniel has suggested in the comments to the question. But if you can't - try executing dumpsys activity activities and see if you could find the info you are looking for there. Take a look at the Running activities section and see if your activity disappears from the list when finished.

Upvotes: 0

Related Questions