没有显示FB登录界面

时间:2012-11-08 06:51:36

标签: facebook blackberry

我无法显示facebook登录界面,我已经下载了facebook blackberry API https://sourceforge.net/projects/facebook-bb-sdk/, 但它显示了我的Facebook的当前用户,如果没有登录用户然后它应该打开登录屏幕,但它没有显示,我使用以下代码: 要检索当前用户(同步):

    User user = fb.getCurrentUser();
    To retrieve the current user (Asynchronously):
    fb.getCurrentUser(new BasicAsyncCallback() {
    public void onComplete(com.blackberry.facebook.inf.Object[] objects, final java.lang.Object state) {
    user = (User) objects[0];
    // do whatever you want
    }
    public void onException(final Exception e, final java.lang.Object state) {
    e.printStackTrace();
    // do whatever you want
    }
    });

我的问题是,当设备没有任何面书用户时,我想要面子书登录屏幕。

1 个答案:

答案 0 :(得分:1)

You are trying to get the current user asynchronously. Don't do that if you want to see the login screen. Do this instead:

Runnable a = new Runnable(){
    public void run(){
        ApplicationSettings as = new ApplicationSettings(YOUR_FACEBOOK_NEXT_URL, YOUR_FACEBOOK_APPLICATION_ID, YOUR_FACEBOOK_APPLICATION_SECRET, Facebook.Permissions.ALL_PERMISSIONS);

        Facebook fb = Facebook.getInstance(as);
        try {
        User user = fb.getCurrentUser();
        if( user != null){
            //do whatever
            }
    } catch(FacebookException e){
            //Crazy happened!
    }
    }
};

UiApplication.getUiApplication().invokeLater(a);

I think this should solve your problem. Cheers.