简体   繁体   中英

How can I hook onto onCreate of the Activity in an Android instrumentation test?

I want to execute some code in my instrumentation test after my Activity's onCreate but before its onResume . Is there any way I can achieve this in the test code, without modifying production code?

My test class extends ActivityInstrumentationTestCase2 . It's a gradle project running under the latest Android Studio.

I want to execute some code in my instrumentation test after my Activity's onCreate but before its onResume.

Try onStart() :

在此处输入图片说明

Docs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM