I follow this tutorial https://developers.facebook.com/docs/howtos/androidsdk/3.0/native-login/ for login process. It's working tith facebook native app, but without native app, first it shows an error, then i click Okay, then again click login button, it's working. I don't understand why doesn't work in the first time?
i don't understand what is the problem? Is it bug?
Updated: Here is the code.
btnFacebook.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Session session = Session.getActiveSession();
if (!session.isOpened() && !session.isClosed()) {
session.openForRead(new Session.OpenRequest(
UserLoginActivity.this).setPermissions(
Arrays.asList("basic_info", "email")).setCallback(
statusCallback));
}
else {
Session.openActiveSession(UserLoginActivity.this, true,
statusCallback);
}
}
});
private class SessionStatusCallback implements Session.StatusCallback {
@Override
public void call(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
final String token = session.getAccessToken();
Request.executeMeRequestAsync(session,
new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user,
Response response) {
if (user != null) {
new AsyncFaceLogin(UserLoginActivity.this)
.execute(user.getId(),user.getFirstName(),user.getLastName(),(String)user.getProperty("email"),token);
}
}
});
}
}
}
On your Facebook Developers app dashboard page, make sure the sandbox mode is disabled. Also, you might want to make sure your App ID and API key are correctly set in your code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.