Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin inheritnce - No value passed for parameter context

Tags:

android

kotlin

I'm trying to build an AccountAuthenticator class with kotlin for android. But when trying to implement the AbstractAccountAuthenticator class I get the following exception at compile:

No value passed for parameter context

I'm not entirely sure what it means and can't find anything on how to solve it.

Here is the relevant code:

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

class AccountAuthenticator: AbstractAccountAuthenticator() {}

Does anyone know what this means, why, and how to fix it?

like image 538
NDevox Avatar asked Jun 20 '17 07:06

NDevox


Video Answer


2 Answers

AbstractAccountAuthenticator's constructor takes a Context context parameter. So you'll have to pass a Context to it somehow, for example, your AccountAuthenticator could also have a Context parameter:

class AccountAuthenticator(context: Context): AbstractAccountAuthenticator(context) {}
like image 187
zsmb13 Avatar answered Sep 18 '22 06:09

zsmb13


I don't know much about Kotlin but AbstractAccountAuthenticator constructor takes a Context see here.

So I guess you have to implement this constructor and other related abstract methods.

like image 38
Gent Ahmeti Avatar answered Sep 21 '22 06:09

Gent Ahmeti