Accessing application context from TestSuite in Setup() before calling getActivity()

前端 未结 6 908
太阳男子
太阳男子 2020-12-08 09:42

I have an Activity that pulls an object from an Application extended class (application context) from within the OnCreate() method.

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 10:19

    You can get the application context using the androidx.test.core.app.ApplicationProvider.getApplicationContext(). Cast that to your application and it should be the right context.

提交回复
热议问题