I'm trying to check if the user is already signed in to google in kotlin.
fun isSignedIn(): Boolean {
println(FirebaseAuth.getInstance().currentUser)
println(GoogleSignIn.getLastSignedInAccount(this))
return GoogleSignIn.getLastSignedInAccount(this) != null
}
However I'm not sure why I'm getting the null pointer exception for the line GoogleSignIn.getLastSignedInAccount(this):
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
I've been looking at other stackoverflow threads and following what has been suggested, but I'm not sure what the problem is.
Am I overlooking something very simple? Thank you.