2012-11-08 149 views
-1

我無法顯示Facebook登錄屏幕,我已經下載了Facebook黑莓API https://sourceforge.net/projects/facebook-bb-sdk/, ,但它顯示我當前的facebook用戶,如果沒有登錄用戶,則應該打開登錄屏幕上,但它沒有顯示,我使用下面的代碼: 獲取當前用戶(同步):未顯示FB登錄屏幕

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
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.