【发布时间】:2018-09-17 09:13:48
【问题描述】:
我正在尝试根据用户的电子邮件是否经过验证以及他们是否有用户名来将用户发送到一个活动。到目前为止,我的代码如下所示:
if (isEmailVerified == true) {
if (user.displayName == null) {
startIntent(NewUserLayoutProfile)
} else {
startIntent(MainActivity)
}
}
if (isEmailVerified == false) {
startIntent(ResendEmailVerification)
}
和
private fun startIntent (theIntent: Activity) {
val i = Intent(this, theIntent::class.java)
startActivity(i)
}
如何通过活动?我尝试将它作为字符串传递,但没有奏效。我在这里做错了什么?
【问题讨论】:
-
你要像
MainActivity::class.java一样把::class.java传递给函数,参数可以是theIntent: Class<*> -
请将此添加为答案,以便我将答案归功于您。
-
不,这个问题是将意图发送给一个方法。此外,它还在意图中添加了
.putExtra。完全不是一回事。
标签: android android-intent kotlin