protected void closeAllActivities() throws Exception {
  try {
    for (int i=0; i < 20; i++) {
      pressBack();
      Thread.sleep(100);
    }
  }
 catch (  NoActivityResumedException|InterruptedException e) {
  }
}

protected void closeAllActivities ( ) throws Exception { try { for ( int i = 0 ; i < 20 ; i ++ ) { pressBack ( ) ; Thread . sleep ( 100 ) ; } } catch ( NoActivityResumedException | InterruptedException e ) { } }
closes all activities on the stack .
