public RecordBuilderImpl snapActivity(final Activity activity) {
    if (!isUiThread()) {
      return runCallableOnUiThread(
              new Callable<RecordBuilderImpl>() {
                @Override
                public RecordBuilderImpl call() {
                  return snapActivity(activity);
                }
              })
          .setTestClass(TestNameDetector.getTestClass())
          .setTestName(TestNameDetector.getTestName());
    }
    View rootView = Preconditions.checkNotNull(activity.getWindow()).getDecorView();
    return snap(rootView);
  }
Snaps a screenshot of the activity using the testName as the name.
core/src/main/java/com/facebook/testing/screenshot/internal/ScreenshotImpl.java