开发者

Facebook with Android: unexpected NullPointerException

I have some code that connects my app to Facebook. When you log in you proceed to the next activity. If you are already logged in when you start the app you miss out the log in section. On the following page I want to be able to log out, every time I press logout I get a null pointer. Can anyone help?

My code for log out is:

private void logout() {
    try {

        facebookConnector.getFacebook().logout(getApplicationContext());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

The code that is run when the app is started to check if the person has logged on is:

if (facebookConnector.getFacebook().isSessionValid()) {
        Intent i = new Intent(facebook.this, facebook2.class);
        startActivity(i);
        finish();
    }

A print screen of my error can be seen here:

Facebook with Android: unexpected NullPointerException

Any help would be great. If you need more info plea开发者_高级运维se comment and I will provide asap.


facebookConnector.getFacebook() seems to return null

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜