this is my new code the line
LoginManager.getInstance().logInWithReadPermissions(this, listOf("public_profile", "email"))
and this line is the error
super.onActivityResult(requestCode, resultCode, data)
class CommonMethods{
lateinit var callbackManager : CallbackManager
companion object callFacebook{
fun onPressFacebookLogin(btn_fb_login:View,) {
val mContext = btn_fb_login.context
btn_fb_login.setOnClickListener(View.OnClickListener {
// Login
var callbackManager = CallbackManager.Factory.create()
LoginManager.getInstance().logInWithReadPermissions(this, listOf("public_profile", "email"))
LoginManager.getInstance().registerCallback(callbackManager,
object : FacebookCallback<LoginResult> {
override fun onSuccess(loginResult: LoginResult) {
Log.d("MainActivity", "Facebook token: " + loginResult.accessToken.token)
mContext.startActivity(Intent(mContext, MainActivity::class.java))
}
override fun onCancel() {
Log.d("MainActivity", "Facebook onCancel.")
}
override fun onError(error: FacebookException) {
Log.d("MainActivity", "Facebook onError.")
}
})
})
}
}
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
callbackManager?.onActivityResult(requestCode, resultCode, data)
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…