I am implementing a Facebook login facility on Android which seems to work OK on the emulator and on Google Nexus device. However the authorization seems to be cancelled by the user on HTC Desire S and so the onComplete()
is never called. The only difference I found is that HTC has a built in facebook application. This is the code I am using:
private void Login(){
facebook.authorize(this,new String[] {"email"}, new Facebook.DialogListener() {
@Override
public void onComplete(Bundle values) {
Log.d("Auth","onCompleteCalled");
}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {
Log.d("Auth","Cancelled");
}
});
The error message comes from this section of Facebook SDK code:
} else if (resultCode == Activity.RESULT_CANCELED) {
// An Android error occured.
if (data != null) {
Log.d("Facebook-auth开发者_如何学Pythonorize",
"Login failed: " + data.getStringExtra("error"));
mAuthDialogListener.onError(
new DialogError(
data.getStringExtra("error"),
data.getIntExtra("error_code", -1),
data.getStringExtra("failing_url")));
// User pressed the 'back' button.
} else {
Log.d("Facebook-authorize", "Login canceled by user."); //This is the error I get
mAuthDialogListener.onCancel();
}
Please Update below code of your application, it will solve your problem.
public void loginAndPostToWall() {
facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH,
new LoginDialogListener());
}
精彩评论