Anyone know how to write an inline Intent outside ...
# android
c
Anyone know how to write an inline Intent outside of an OnClickListener Lambda? I know inside the lambda, you can write like this
Copy code
view.setOnClickListener { v->
    v.context.startActivity(Intent(v.context, NextClass::class.java))
}
but if I try to write it outside the lambda, I get an error saying that Intent needs a FLAG_CLEAR_NEW_TASK. But Idk where to put it? Any suggestions?
t
Calling startActivity with a context that isn’t an activity requires a new task. I THINK this also applies to fragments - because fragments can in theory be detached and reattached, which would break the backstack. What kind of class is this lambda in?
c
It is actually in the bind() function of my GroupieViewHolder adapter. I use Groupie to help me with RecyclerViews