login Facebook registerCallback not called
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Here is my onCreate method:
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_social_login);
init();
hideActiveSocialNetworks();
FacebookSdk.sdkInitialize(getApplicationContext());
CallbackManager callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// not called
Log.d("fb_login_sdk", "callback success");
}
@Override
public void onCancel() {
// not called
Log.d("fb_login_sdk", "callback cancel");
}
@Override
public void onError(FacebookException e) {
// not called
Log.d("fb_login_sdk", "callback onError");
}
});
final Activity activity = this;
findViewById(R.id.fb_login_sdk).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("fb_login_sdk", "click");
List<String> perm = new ArrayList<String>();
perm.add("user_friends");
LoginManager.getInstance().logInWithReadPermissions(activity, perm);
}
});
}
After login the onSuccess(), onCancel(), onError() methods are not fired.
Documentation: https://developers.facebook.com/docs/facebook-login/android/v2.3
java



add a comment |
Here is my onCreate method:
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_social_login);
init();
hideActiveSocialNetworks();
FacebookSdk.sdkInitialize(getApplicationContext());
CallbackManager callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// not called
Log.d("fb_login_sdk", "callback success");
}
@Override
public void onCancel() {
// not called
Log.d("fb_login_sdk", "callback cancel");
}
@Override
public void onError(FacebookException e) {
// not called
Log.d("fb_login_sdk", "callback onError");
}
});
final Activity activity = this;
findViewById(R.id.fb_login_sdk).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("fb_login_sdk", "click");
List<String> perm = new ArrayList<String>();
perm.add("user_friends");
LoginManager.getInstance().logInWithReadPermissions(activity, perm);
}
});
}
After login the onSuccess(), onCancel(), onError() methods are not fired.
Documentation: https://developers.facebook.com/docs/facebook-login/android/v2.3
java



I had the exact same problem following the facebook docs. Thanks for posting your question.
– raddevus
Dec 15 '15 at 15:49
add a comment |
Here is my onCreate method:
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_social_login);
init();
hideActiveSocialNetworks();
FacebookSdk.sdkInitialize(getApplicationContext());
CallbackManager callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// not called
Log.d("fb_login_sdk", "callback success");
}
@Override
public void onCancel() {
// not called
Log.d("fb_login_sdk", "callback cancel");
}
@Override
public void onError(FacebookException e) {
// not called
Log.d("fb_login_sdk", "callback onError");
}
});
final Activity activity = this;
findViewById(R.id.fb_login_sdk).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("fb_login_sdk", "click");
List<String> perm = new ArrayList<String>();
perm.add("user_friends");
LoginManager.getInstance().logInWithReadPermissions(activity, perm);
}
});
}
After login the onSuccess(), onCancel(), onError() methods are not fired.
Documentation: https://developers.facebook.com/docs/facebook-login/android/v2.3
java



Here is my onCreate method:
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_social_login);
init();
hideActiveSocialNetworks();
FacebookSdk.sdkInitialize(getApplicationContext());
CallbackManager callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// not called
Log.d("fb_login_sdk", "callback success");
}
@Override
public void onCancel() {
// not called
Log.d("fb_login_sdk", "callback cancel");
}
@Override
public void onError(FacebookException e) {
// not called
Log.d("fb_login_sdk", "callback onError");
}
});
final Activity activity = this;
findViewById(R.id.fb_login_sdk).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("fb_login_sdk", "click");
List<String> perm = new ArrayList<String>();
perm.add("user_friends");
LoginManager.getInstance().logInWithReadPermissions(activity, perm);
}
});
}
After login the onSuccess(), onCancel(), onError() methods are not fired.
Documentation: https://developers.facebook.com/docs/facebook-login/android/v2.3
java



java



asked Jun 2 '15 at 14:44
Jerome AnsiaJerome Ansia
3,87093991
3,87093991
I had the exact same problem following the facebook docs. Thanks for posting your question.
– raddevus
Dec 15 '15 at 15:49
add a comment |
I had the exact same problem following the facebook docs. Thanks for posting your question.
– raddevus
Dec 15 '15 at 15:49
I had the exact same problem following the facebook docs. Thanks for posting your question.
– raddevus
Dec 15 '15 at 15:49
I had the exact same problem following the facebook docs. Thanks for posting your question.
– raddevus
Dec 15 '15 at 15:49
add a comment |
3 Answers
3
active
oldest
votes
Missing this on my activity:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
1
You should mark this as correct answer
– Bart Bergmans
Sep 18 '15 at 13:42
2
Thank you! This saved my life.
– Xi Wei
Oct 14 '16 at 17:25
you are welcome, happy to help!
– Jerome Ansia
Oct 14 '16 at 18:59
add a comment |
Your code will work when you add this to your activity class
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
add a comment |
Here is checklist to check whether your Facebook Sdk setup is correct:-
Check your manifest if you have setup Facebook initialization properly.
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
Create Facebook CallBackManager variable
var fbCallManager = CallbackManager.Factory.create()
On Click of Login with Facebook button. Put your required permission in Array.
LoginManager.getInstance()
.logInWithReadPermissions(this, Arrays.asList("public_profile", "email", "user_friends"))
LoginManager.getInstance().registerCallback(fbCallManager, object : FacebookCallback<LoginResult> {
override fun onSuccess(result: LoginResult?) {
//login success
}
override fun onCancel() {
//login cancelled by user
}
override fun onError(error: FacebookException?) {
//login error handle exception
}
})
}
Add callback result in onActivityResult method
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
fbCallManager.onActivityResult(requestCode, resultCode, data)
}
Provide the Development and Release Key Hashes for Your
keytool -exportcert -alias androiddebugkey -keystore "C:UsersUSERNAME.androiddebug.keystore" | "PATH_TO_OPENSSL_LIBRARYbinopenssl" sha1 -binary | "PATH_TO_OPENSSL_LIBRARYbinopenssl" base64
Download openssl from here
- Setup your Keyhash and Launcher activity in Facebook developer console.
References : Facebook
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30599301%2flogin-facebook-registercallback-not-called%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Missing this on my activity:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
1
You should mark this as correct answer
– Bart Bergmans
Sep 18 '15 at 13:42
2
Thank you! This saved my life.
– Xi Wei
Oct 14 '16 at 17:25
you are welcome, happy to help!
– Jerome Ansia
Oct 14 '16 at 18:59
add a comment |
Missing this on my activity:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
1
You should mark this as correct answer
– Bart Bergmans
Sep 18 '15 at 13:42
2
Thank you! This saved my life.
– Xi Wei
Oct 14 '16 at 17:25
you are welcome, happy to help!
– Jerome Ansia
Oct 14 '16 at 18:59
add a comment |
Missing this on my activity:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
Missing this on my activity:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
answered Jun 2 '15 at 14:50
Jerome AnsiaJerome Ansia
3,87093991
3,87093991
1
You should mark this as correct answer
– Bart Bergmans
Sep 18 '15 at 13:42
2
Thank you! This saved my life.
– Xi Wei
Oct 14 '16 at 17:25
you are welcome, happy to help!
– Jerome Ansia
Oct 14 '16 at 18:59
add a comment |
1
You should mark this as correct answer
– Bart Bergmans
Sep 18 '15 at 13:42
2
Thank you! This saved my life.
– Xi Wei
Oct 14 '16 at 17:25
you are welcome, happy to help!
– Jerome Ansia
Oct 14 '16 at 18:59
1
1
You should mark this as correct answer
– Bart Bergmans
Sep 18 '15 at 13:42
You should mark this as correct answer
– Bart Bergmans
Sep 18 '15 at 13:42
2
2
Thank you! This saved my life.
– Xi Wei
Oct 14 '16 at 17:25
Thank you! This saved my life.
– Xi Wei
Oct 14 '16 at 17:25
you are welcome, happy to help!
– Jerome Ansia
Oct 14 '16 at 18:59
you are welcome, happy to help!
– Jerome Ansia
Oct 14 '16 at 18:59
add a comment |
Your code will work when you add this to your activity class
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
add a comment |
Your code will work when you add this to your activity class
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
add a comment |
Your code will work when you add this to your activity class
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
Your code will work when you add this to your activity class
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
edited Jul 26 '18 at 15:56


thechaoticpanda
599
599
answered Apr 13 '18 at 12:08


Keshav GeraKeshav Gera
3,0491829
3,0491829
add a comment |
add a comment |
Here is checklist to check whether your Facebook Sdk setup is correct:-
Check your manifest if you have setup Facebook initialization properly.
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
Create Facebook CallBackManager variable
var fbCallManager = CallbackManager.Factory.create()
On Click of Login with Facebook button. Put your required permission in Array.
LoginManager.getInstance()
.logInWithReadPermissions(this, Arrays.asList("public_profile", "email", "user_friends"))
LoginManager.getInstance().registerCallback(fbCallManager, object : FacebookCallback<LoginResult> {
override fun onSuccess(result: LoginResult?) {
//login success
}
override fun onCancel() {
//login cancelled by user
}
override fun onError(error: FacebookException?) {
//login error handle exception
}
})
}
Add callback result in onActivityResult method
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
fbCallManager.onActivityResult(requestCode, resultCode, data)
}
Provide the Development and Release Key Hashes for Your
keytool -exportcert -alias androiddebugkey -keystore "C:UsersUSERNAME.androiddebug.keystore" | "PATH_TO_OPENSSL_LIBRARYbinopenssl" sha1 -binary | "PATH_TO_OPENSSL_LIBRARYbinopenssl" base64
Download openssl from here
- Setup your Keyhash and Launcher activity in Facebook developer console.
References : Facebook
add a comment |
Here is checklist to check whether your Facebook Sdk setup is correct:-
Check your manifest if you have setup Facebook initialization properly.
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
Create Facebook CallBackManager variable
var fbCallManager = CallbackManager.Factory.create()
On Click of Login with Facebook button. Put your required permission in Array.
LoginManager.getInstance()
.logInWithReadPermissions(this, Arrays.asList("public_profile", "email", "user_friends"))
LoginManager.getInstance().registerCallback(fbCallManager, object : FacebookCallback<LoginResult> {
override fun onSuccess(result: LoginResult?) {
//login success
}
override fun onCancel() {
//login cancelled by user
}
override fun onError(error: FacebookException?) {
//login error handle exception
}
})
}
Add callback result in onActivityResult method
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
fbCallManager.onActivityResult(requestCode, resultCode, data)
}
Provide the Development and Release Key Hashes for Your
keytool -exportcert -alias androiddebugkey -keystore "C:UsersUSERNAME.androiddebug.keystore" | "PATH_TO_OPENSSL_LIBRARYbinopenssl" sha1 -binary | "PATH_TO_OPENSSL_LIBRARYbinopenssl" base64
Download openssl from here
- Setup your Keyhash and Launcher activity in Facebook developer console.
References : Facebook
add a comment |
Here is checklist to check whether your Facebook Sdk setup is correct:-
Check your manifest if you have setup Facebook initialization properly.
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
Create Facebook CallBackManager variable
var fbCallManager = CallbackManager.Factory.create()
On Click of Login with Facebook button. Put your required permission in Array.
LoginManager.getInstance()
.logInWithReadPermissions(this, Arrays.asList("public_profile", "email", "user_friends"))
LoginManager.getInstance().registerCallback(fbCallManager, object : FacebookCallback<LoginResult> {
override fun onSuccess(result: LoginResult?) {
//login success
}
override fun onCancel() {
//login cancelled by user
}
override fun onError(error: FacebookException?) {
//login error handle exception
}
})
}
Add callback result in onActivityResult method
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
fbCallManager.onActivityResult(requestCode, resultCode, data)
}
Provide the Development and Release Key Hashes for Your
keytool -exportcert -alias androiddebugkey -keystore "C:UsersUSERNAME.androiddebug.keystore" | "PATH_TO_OPENSSL_LIBRARYbinopenssl" sha1 -binary | "PATH_TO_OPENSSL_LIBRARYbinopenssl" base64
Download openssl from here
- Setup your Keyhash and Launcher activity in Facebook developer console.
References : Facebook
Here is checklist to check whether your Facebook Sdk setup is correct:-
Check your manifest if you have setup Facebook initialization properly.
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
Create Facebook CallBackManager variable
var fbCallManager = CallbackManager.Factory.create()
On Click of Login with Facebook button. Put your required permission in Array.
LoginManager.getInstance()
.logInWithReadPermissions(this, Arrays.asList("public_profile", "email", "user_friends"))
LoginManager.getInstance().registerCallback(fbCallManager, object : FacebookCallback<LoginResult> {
override fun onSuccess(result: LoginResult?) {
//login success
}
override fun onCancel() {
//login cancelled by user
}
override fun onError(error: FacebookException?) {
//login error handle exception
}
})
}
Add callback result in onActivityResult method
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
fbCallManager.onActivityResult(requestCode, resultCode, data)
}
Provide the Development and Release Key Hashes for Your
keytool -exportcert -alias androiddebugkey -keystore "C:UsersUSERNAME.androiddebug.keystore" | "PATH_TO_OPENSSL_LIBRARYbinopenssl" sha1 -binary | "PATH_TO_OPENSSL_LIBRARYbinopenssl" base64
Download openssl from here
- Setup your Keyhash and Launcher activity in Facebook developer console.
References : Facebook
answered Jan 3 at 2:52
AkshayAkshay
647415
647415
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30599301%2flogin-facebook-registercallback-not-called%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I had the exact same problem following the facebook docs. Thanks for posting your question.
– raddevus
Dec 15 '15 at 15:49