How to stop and restart an activity in an android instrumentation test?

后端 未结 5 466
感情败类
感情败类 2021-02-01 20:43

I\'m trying to write an Android activity instrumentation test that stops (onPause(), then onStop()) and restarts the current activity. I tried

5条回答
  •  无人共我
    2021-02-01 21:36

    Change your code as follows:

    mActivity.finish();
        setActivity(null);
        mActivity = this.getActivity();
    

    A full explanation can be found in this question

提交回复
热议问题