In Java, to override method when instantiating new object we can do this
public ActivityTestRule<MainActivity> rule = new ActivityTestRule<MainActivity>(
MainActivity.class) {
@Override
protected void beforeActivityLaunched() {
// implement code
super.beforeActivityLaunched();
}
};
How to do that in Kotlin? I tried this code but it failed to compile.
@Rule @JvmField
var rule = ActivityTestRule<MainActivity>(MainActivity::class.java) {
override fun beforeActivityLaunched() {
super.beforeActivityLaunched()
}
}