-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 に答える