I tried to run it several ways but callbackManager called twice and only at login. when I press fb_login_button again (for logout) it only executes once . The toast is used to show it on screen but they both show the same things(executed twice).
fb_login_button.setOnClickListener({
callbackManager = CallbackManager.Factory.create()
LoginManager.getInstance().logInWithReadPermissions(this, arrayListOf("public_profile","email"))
LoginManager.getInstance().registerCallback(callbackManager,
object : FacebookCallback<LoginResult>{
override fun onSuccess(result: LoginResult?) {
Toast.makeText(this@SignIN,"Success",Toast.LENGTH_LONG).show()
Log.d("ss",":'(")
}
override fun onCancel() {
Toast.makeText(this@SignIN,"Cancelled Facebook",Toast.LENGTH_LONG).show()
}
override fun onError(error: FacebookException?) {
Toast.makeText(this@SignIN,"Error Facebook",Toast.LENGTH_LONG).show()
}
})
})
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
callbackManager?.onActivityResult(requestCode, resultCode, data)
}
After searching alt I got a few posts regarding same issue but on different activities. onActivityResult executing twice onViewCreated called twice OnActivityResult getting called twice in Android onActivityResult called twice