Android ddmlib: verify activity is running

I needed to find a way to verify if Android activity is running from java project, which uses ddmlib to connect to Android devices via USB.
For this purposes, I created a class, which implements IShellOutputReceiver

This is needed to get output of the shell command we are executing in the following function: