Say I have 2 apps A & B running. A got pushed back after B was clicked, so B was on top of A making A invisible.
How do I bring A back to the top/front using adb commands?
It might has something to do with FocusedWindow or something but I'm not sure.
If you launch that app again using am, previous activities may be terminated causing problems or worse, a new instance maybe started (I'm not sure if that's the case). To put it in plain terms, I don't want to restart A nor do I want to lose any changes made in A, so A must be brought back to top/front instead of restarted.
If you know the app's package name and activity, then try following command
adb shell am start --activity-single-top com.package.your_app/.YourActivity
--activity-single-top
flag will make sure that activity which needs to be started if happens to be the app's foreground activity, then it will be resumed.