java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
当我尝试以隐式意图打开链接时出现此错误。我正在通过ImageView 上的适配器类调用活动openUrl(url: String)
。Settings.kt
SettingsAdapter.kt
setOnClcikListener
SettingsAdapter.kt类
private val settings = Settings()
youtubeLink.setOnClickListener {
val url = "https://www.youtube.com/watch?v=i-0FtaAadeM"
settings.openUrl(url)
}
Settings.kt活动
fun openUrl(url: String) {
val intent = Intent(Intent.ACTION_VIEW,Uri.parse(url))
startActivity(intent)
}