https://kotlinlang.org logo
#android
Title
# android
c

Cyberpunk Keanu

11/15/2019, 12:46 PM
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

thymecypher

11/15/2019, 3:47 PM
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

Cyberpunk Keanu

11/15/2019, 4:14 PM
It is actually in the bind() function of my GroupieViewHolder adapter. I use Groupie to help me with RecyclerViews