https://kotlinlang.org logo
Title
t

Tyler

05/22/2018, 3:29 PM
Hi, I keep seeing intents with java classes as an argument, but I'm not sure how to use a Kotlin one instead?
val i = Intent(this, ExampleJavaClass::class.java)
k

karelpeeters

05/22/2018, 3:30 PM
That's the code for a Kotlin class too.
::class.java
doesn't mean "this is a Java class", it means "give me a
java.lang.Class
instead of a `KClass`".
(for next time, there's #android for android-specific Kotlin questions)
✔️ 1
t

Tyler

05/22/2018, 3:31 PM
ahh sorry, I thought it was so basic that I should be asking here 😕
a

arekolek

05/22/2018, 3:31 PM
to add to above,
Intent
constructor expects
Class
not
KClass
, that's why you need to use
::class.java
k

karelpeeters

05/22/2018, 3:34 PM
Sure, this question was a bit of a grey area, it was just a tip.