According to the Android documentation, Instrumentation.ActivityMonitor is able to return an Activity that is being started. That is, you pass it an IntentFilter in its constructor so it knows what it's looking for. My question is, is it possible for ActivityMontior to look for any kind of Activity starting? In other words, is it possible to use ActivityMonitor to return the top most Activity showing on the foreground?
Yes, ActivityMonitor will wait for any Activity that matches the IntentFilter, which when started will be the top most, unless you are using some flags like FLAG_ACTIVITY_PREVIOUS_IS_TOP that may affect this ordering.