robolectric 2 - create activity with intent

前端 未结 4 711
鱼传尺愫
鱼传尺愫 2021-01-04 18:55

Does creating an activity using the .withIntent() not work in Robolectric 2? I\'m doing the following

    activity = Robolectric.buildActivity(         


        
4条回答
  •  天涯浪人
    2021-01-04 19:52

    This is a case where a fluent-style API kinds of leads you down the wrong path...

    You want to:

    activity = Robolectric.buildActivity(MyActivity.class)
                            .withIntent(intent)
                            .create()
                            .get();
    

    so that the intent is provided to the builder before it calls onCreate().

提交回复
热议问题