-1

我无法显示 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
    }
    });

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

4

1 回答 1

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.
于 2012-11-26T23:53:59.873 回答