Facebook登录不在android中

时间:2017-04-26 07:21:45

标签: android facebook facebook-android-sdk

我正在开发一个有facebook登录的应用程序,我已经成功实现了它并进行了多次测试,它工作得很好,但是从昨天它停止工作而没有给出任何错误,我已经调试了我的应用程序但是找不到任何问题,有谁可以帮我解决问题在哪里?

logcat的

04-26 13:03:54.397 5765-5765/com.abc.allaboutcity W/BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 5765
04-26 13:03:54.404 5765-5794/com.abc.allaboutcity E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f97c8e10b40
04-26 13:03:54.503 5765-5794/com.abc.allaboutcity E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f97c69aa370
04-26 13:03:54.749 5765-5794/com.abc.allaboutcity E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f97c69a9110
04-26 13:03:54.796 5765-6103/com.abc.allaboutcity W/chromium: [WARNING:spdy_session.cc(2527)] Received WINDOW_UPDATE for invalid stream 15

的java

 FacebookSdk.sdkInitialize( getApplicationContext() );
        setContentView( R.layout.activity_login );
        init();
        loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() {

            @Override
            public void onSuccess(LoginResult loginResult) {
                GraphRequest request = GraphRequest.newMeRequest(
                        loginResult.getAccessToken(),
                        new GraphRequest.GraphJSONObjectCallback() {
                            @Override
                            public void onCompleted(JSONObject object, GraphResponse response) {
                                Log.v( "Main", response.toString() );
                                setProfileToView( object );
                                new FACEBOOK_LOGIN().execute();
                            }
                        } );
                Bundle parameters = new Bundle();
                parameters.putString( "fields", "id,name,email,gender, birthday,cover,picture,first_name,last_name" );
                request.setParameters( parameters );
                request.executeAsync();
            }

            @Override
            public void onCancel() {
                // App code
            }

            @Override
            public void onError(FacebookException exception) {
                Toast.makeText( LoginActivity.this, "error to Login Facebook", Toast.LENGTH_SHORT ).show();
            }
        } );

  void init() {
        callbackManager = CallbackManager.Factory.create();
...
.
.
.
}

1 个答案:

答案 0 :(得分:1)

首先检查您是否使用Facebook SDK的最新版本,因为他们在图谱API中有更改,他们弃用了一些旧版本。

您的代码中未包含的另一件事是,LoginButton中您需要设置读取权限

loginButton.setReadPermissions("email");

另请确保使用calbackManager

中的onActivityResult转发登录结果
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    callbackManager.onActivityResult(requestCode, resultCode, data);
}

但是你能澄清一下这段代码的运行方式吗?是在Fragment还是Activity

尝试按照此处描述的每一步操作,以确保您不会错过任何内容:

https://developers.facebook.com/docs/facebook-login/android