无法通过facebook android sdk获取facebook用户信息

无法通过facebook android sdk获取facebook用户信息,android,facebook,facebook-graph-api,Android,Facebook,Facebook Graph Api,我将我的主要活动onCreate方法设置为: protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); testtext = (TextView) findViewById(R.id.tes

我将我的主要活动onCreate方法设置为:

    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    testtext = (TextView) findViewById(R.id.testtext);

    loginButton = (LoginButton) findViewById(R.id.authButton);
    loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() {
        @Override
        public void onUserInfoFetched(GraphUser user) {
            MainActivity.this.user = user;
            System.out.println("user:"+user.getFirstName());
            testGet();

        }
    });
}
testGet()方法用于测试获取用户的新闻提要:

public void testGet(){
    String[] requests = {"/me/home"};
    RequestBatch requestBatch = new RequestBatch();
    for (final String request : requests) {
        requestBatch.add(new Request(Session.getActiveSession(), 
                request, null, null, new Request.Callback() {
            public void onCompleted(Response response) {
                GraphObject graphObject = response.getGraphObject();
                String s = testtext.getText().toString();
                if (graphObject != null) {
                        s = s + String.format("%s\n%s\n%s\n%s\n\n", 
                                graphObject.getProperty("name"), 
                                graphObject.getProperty("description"),
                                graphObject.getProperty("create_time"),
                                graphObject.getProperty("type"));
                }
                s = s + "\n hello, " + user.getFirstName() + "!\n";
                testtext.setText(s);
                System.out.println(s);
                testtext.setText(s);
            }
        }));
    }
    requestBatch.executeAsync();
}
然而,在Android设备上运行应用程序后,它甚至在我点击facebook登录按钮之前就崩溃了

错误是:

java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String com.facebook.model.GraphUser.getFirstName()' on a null object reference
这里有什么问题?为什么在我登录之前就调用了onUserInfoFetched()

顺便问一下,有人知道我的testGet()方法获取新闻提要是否正确吗

谢谢

更换这个

GraphObject graphObject = response.getGraphObject();
由此

JSONObject object = user.getInnerJSONObject();