Created
November 2, 2019 04:22
-
-
Save jampajeen/e6ea1fa9583601921e2ef860d827370a to your computer and use it in GitHub Desktop.
FIrebase facebook login button (custom button)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Button btnFacebook = findViewById(R.id.btn_facebook); | |
Drawable leftDrawable = AppCompatResources.getDrawable(this, R.drawable.baseline_power_settings_new_black_18dp); | |
btnFacebook.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, null, null, null); | |
// Start Facebook integration | |
LoginManager fbLoginManager = com.facebook.login.LoginManager.getInstance(); | |
mCallbackManager = CallbackManager.Factory.create(); | |
fbLoginManager.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() { | |
@Override | |
public void onSuccess(LoginResult loginResult) { | |
Log.d(TAG, "facebook:onSuccess:" + loginResult); | |
handleFacebookAccessToken(loginResult.getAccessToken()); | |
} | |
@Override | |
public void onCancel() { | |
Log.d(TAG, "facebook:onCancel"); | |
// ... | |
} | |
@Override | |
public void onError(FacebookException error) { | |
Log.d(TAG, "facebook:onError", error); | |
// ... | |
} | |
}); | |
btnFacebook.setOnClickListener(v -> fbLoginManager.logInWithReadPermissions( | |
this, | |
Arrays.asList("email", "public_profile", "user_birthday"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment