Android: check if app closes to background

hi all,

tap Back on Home screen should close the app to background. what’s the best solution to check that?

android, ruby
thank you

  1. try to get current activity and check if your app is there
    // or
  2. try to look for some element that exists in your app. not found = your app not on screen.