testutils/src/main/java/androidx/testutils/FragmentActivityUtils.java
public static <T extends RecreatedActivity> T recreateActivity(
            ActivityTestRule<? extends RecreatedActivity> rule, final T activity)
            throws InterruptedException {
        // Now switch the orientation
        RecreatedActivity.sResumed = new CountDownLatch(1);
        RecreatedActivity.sDestroyed = new CountDownLatch(1);

        runOnUiThreadRethrow(rule, new Runnable() {
            @Override
            public void run() {
                activity.recreate();
            }
        });
        assertTrue(RecreatedActivity.sResumed.await(1, TimeUnit.SECONDS));
        assertTrue(RecreatedActivity.sDestroyed.await(1, TimeUnit.SECONDS));
        T newActivity = (T) RecreatedActivity.sActivity;

        waitForExecution(rule);

        RecreatedActivity.clearState();
        return newActivity;
    }
/**
     * Restarts the RecreatedActivity and waits for the new activity to be resumed.
     *
     * @return The newly-restarted Activity
     */
Restarts the RecreatedActivity and waits for the new activity to be resumed.
@return The newly-restarted Activity
Restarts the RecreatedActivity and waits for the new activity to be resumed . @return The newly - restarted Activity
public static <T extends RecreatedActivity> T recreateActivity(
            ActivityTestRule<? extends RecreatedActivity> rule, final T activity)
            throws InterruptedException {
        RecreatedActivity.sResumed = new CountDownLatch(1);
        RecreatedActivity.sDestroyed = new CountDownLatch(1);
        runOnUiThreadRethrow(rule, new Runnable() {
            @Override
            public void run() {
                activity.recreate();
            }
        });
        assertTrue(RecreatedActivity.sResumed.await(1, TimeUnit.SECONDS));
        assertTrue(RecreatedActivity.sDestroyed.await(1, TimeUnit.SECONDS));
        T newActivity = (T) RecreatedActivity.sActivity;
        waitForExecution(rule);
        RecreatedActivity.clearState();
        return newActivity;
    }
public static < T extends RecreatedActivity > T recreateActivity ( ActivityTestRule < ? extends RecreatedActivity > rule , final T activity ) throws InterruptedException { RecreatedActivity . sResumed = new CountDownLatch ( 1 ) ; RecreatedActivity . sDestroyed = new CountDownLatch ( 1 ) ; runOnUiThreadRethrow ( rule , new Runnable ( ) { @ Override public void run ( ) { activity . recreate ( ) ; } } ) ; assertTrue ( RecreatedActivity . sResumed . await ( 1 , TimeUnit . SECONDS ) ) ; assertTrue ( RecreatedActivity . sDestroyed . await ( 1 , TimeUnit . SECONDS ) ) ; T newActivity = ( T ) RecreatedActivity . sActivity ; waitForExecution ( rule ) ; RecreatedActivity . clearState ( ) ; return newActivity ; }
Restarts the RecreatedActivity and waits for the new activity to be resumed.
Restarts the RecreatedActivity and waits for the new activity to be resumed .
// Now switch the orientation