对于android,FacebookSDK返回的Graphuser为null

时间:2013-06-13 15:17:21

标签: android facebook facebook-graph-api

我搜索了这个主题,在StackOverflow上发现了一些类似的问题但很遗憾没有人帮助过。

这是我使用我的应用程序登录Facebook身份验证的代码。但我每次都收到一个空响应。

    public class FacebookHome extends Activity{

        @Override
        public void onCreate(Bundle iCicle){
            super.onCreate(iCicle);
            setContentView(R.layout.activity_facebookhome);

            // start Facebook Login
              Session.openActiveSession(this, true, new Session.StatusCallback() {
                // callback when session changes state
                @Override
                public void call(Session session, SessionState state, Exception exception) {
                    if (session.isOpened()) {

                        // make request to the /me API
                        Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
                            //
                          // callback after Graph API response with user object
                          @Override
                          public void onCompleted(GraphUser user, Response response) {
                              Log.e("PanicButton",response.toString());
                              if (user != null) {
                                  TextView welcome = (TextView) findViewById(R.id.textView1);
                                  Log.i("PanicButton", user.getFirstName());
                                  welcome.setText("Hello " + user.getFirstName() + "!");
                                }
                          }
                        });

                    }
                }
              });
        }


        @Override
        public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
        }


}

1 个答案:

答案 0 :(得分:0)

检查并确保在您的表现中包含互联网权限:

<uses-permission android:name="android.permission.INTERNET"/>