android–Kotlin inheritnce– 没有为参数上下文传递值

android–Kotlin inheritnce– 没有为参数上下文传递值,第1张

概述我正在尝试使用kotlin为android构建一个AccountAuthenticator类.但是在尝试实现AbstractAccountAuthenticator类时,我在编译时遇到以下异常:没有为参数上下文传递值我不完全确定它意味着什么,也找不到任何解决方法.这是相关代码:importandroid.accounts.AbstractAccountAuthent

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

没有为参数上下文传递

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

这是相关代码:

import androID.accounts.AbstractAccountAuthenticatorimport androID.accounts.Accountimport androID.accounts.AccountAuthenticatorResponseimport androID.os.Bundleclass AccountAuthenticator: AbstractAccountAuthenticator() {}

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

解决方法:

AbstractAccountAuthenticator的constructor采用Context上下文参数.因此,您必须以某种方式将Context传递给它,例如,您的AccountAuthenticator也可能具有Context参数:

class AccountAuthenticator(context: Context): AbstractAccountAuthenticator(context) {}
总结

以上是内存溢出为你收集整理的android – Kotlin inheritnce – 没有为参数上下文传递值全部内容,希望文章能够帮你解决android – Kotlin inheritnce – 没有为参数上下文传递值所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1116479.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存