2013-08-29 126 views
0

我經歷了tutorial併成功實施登錄和註銷流程。但是,這適用於內置登錄按鈕:Facebook的Android 3.0登錄

<com.facebook.widget.LoginButton 
     android:id="@+id/authButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginTop="30dp" 
     /> 

當用戶選擇例如。來自列表中的項目,自定義對話框將顯示「共享」選項。當用戶選擇這個分享選項時,我想登錄他們到Facebook和像ABC這樣的通常的東西想要訪問您的個人資料,ABC想張貼給您的朋友等。

編輯: 我想我有發現what I need,但我很早就遇到了問題。我無法導入FacebookDialog。也不是提供給我,也不當我導入com.facebook.*;

根據thisFacebookDialogcom.facebook.widget包我可以使用。但是,當我輸入import com.facebook.widget。唯一提供的對話框是WebDialog

回答

0

我需要的是Feed dialog

實施例:

private void publishFeedDialog() { 
    Bundle params = new Bundle(); 
    params.putString("name", "New level!"); 
    params.putString("description", "I have reached level " + lvel!"); 
    params.putString("link", "https://play.google.com/store/apps/details?id=com.myapp"); 
    params.putString("picture", "http://myapp.com/Images/icoon.png"); 

     WebDialog feedDialog = (
       new WebDialog.FeedDialogBuilder(this, 
        Session.getActiveSession(), 
        params)) 
       .setOnCompleteListener(new OnCompleteListener() { 

        @Override 
        public void onComplete(Bundle values, 
         FacebookException error) { 
         if (error == null) { 
           // When the story is posted, echo the success 
           // and the post Id. 
           final String postId = values.getString("post_id"); 
           if (postId != null) { 
            //Toast.makeText(getActivity(), "Posted story, id: "+postId, Toast.LENGTH_SHORT).show(); 
           } else { 
            // User clicked the Cancel button 
            //Toast.makeText(getActivity().getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show(); 
           } 
          } else if (error instanceof FacebookOperationCanceledException) { 
           // User clicked the "x" button 
           //Toast.makeText(getActivity().getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show(); 
          } else { 
           // Generic, ex: network error 
           Toast.makeText(getApplicationContext(), 
            "Error sharing app", Toast.LENGTH_SHORT).show(); 
          } 
        } 

       }) 
       .build(); 
      feedDialog.show(); 
}