android - Intents in Kotlin -
so, know in java use launch new activity
intent intent = new intent(this, someactivity.class); startactiviry(intent);
but i'm writting project using kotlin, in kotlin it's
val intent = intent(this,someactivity::class.java) startactivity(intent)
but crashes problem
fatal exception: main process: com.pashabred.passlin, pid: 15243 java.lang.runtimeexception: unable start activity componentinfo{com.pashabred.passlin/com.pashabred.passlin.enterring}: kotlin.kotlinnullpointerexception @ android.app.activitythread.performlaunchactivity(activitythread.java:2325) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2387) @ android.app.activitythread.access$800(activitythread.java:151) @ android.app.activitythread$h.handlemessage(activitythread.java:1303) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5254) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:903) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:698) caused by: kotlin.kotlinnullpointerexception @ com.pashabred.passlin.enterring.oncreate(enterring.kt:17) @ android.app.activity.performcreate(activity.java:5990) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1106) @ android.app.activitythread.performlaunchactivity(activitythread.java:2278) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2387) @ android.app.activitythread.access$800(activitythread.java:151) @ android.app.activitythread$h.handlemessage(activitythread.java:1303) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5254) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:903) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:698)
ensure have (question mark):
override fun oncreate(savedinstancestate: bundle?) { super.oncreate(savedinstancestate) }
instead:
override fun oncreate(savedinstancestate: bundle) { super.oncreate(savedinstancestate) }
Comments
Post a Comment