Kotlin继承 - 没有为参数上下文传递值

NDe*_*vox 3 android kotlin

我正在尝试AccountAuthenticator使用kotlin为android 构建一个类.但是在尝试实现AbstractAccountAuthenticator该类时,我在编译时遇到以下异常:

No value passed for parameter context

我不完全确定它意味着什么,也找不到任何解决方法.

这是相关代码:

import android.accounts.AbstractAccountAuthenticator
import android.accounts.Account
import android.accounts.AccountAuthenticatorResponse
import android.os.Bundle

class AccountAuthenticator: AbstractAccountAuthenticator() {}
Run Code Online (Sandbox Code Playgroud)

有谁知道这意味着什么,为什么,以及如何解决它?

zsm*_*b13 10

AbstractAccountAuthenticator构造函数接受一个Context context参数.所以你必须以Context某种方式传递给它,例如,你AccountAuthenticator也可以有一个Context参数:

class AccountAuthenticator(context: Context): AbstractAccountAuthenticator(context) {}
Run Code Online (Sandbox Code Playgroud)