2014-04-02 118 views
-1

我是新來的Facebook整合,我一直在這幾天工作,我相信我將能夠解決這個問題。我的問題是,我爲分享對話附加的圖像不顯示在Facebook上。facebook分享圖片不顯示在Facebook上通過Android應用程序

enter image description here

這裏是我的代碼:

public class ViewPagerAdapter extends PagerAdapter { 

Context context; 
String[] rank; 
String[] country; 
String[] population; 
int[] bookCover; 
LayoutInflater inflater; 

@覆蓋 公共對象instantiateItem(ViewGroup中的容器,最終詮釋位置){

final PdfHandler pdf = new PdfHandler(context); 
    final int pdfPos = position; 

    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View itemView = inflater.inflate(R.layout.viewpager_item, container, false); 

    ImageView imgflag = (ImageView) itemView.findViewById(R.id.flag); 

    // Capture position and set to the ImageView 
    //imgflag.setScaleType(ScaleType.FIT_XY); 
    imgflag.setImageResource(bookCover[position]); 

    // Add viewpager_item.xml to ViefeewPager 
    ((ViewPager) container).addView(itemView); 

    imgflag.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 

      int data = bookCover[position]; 

      shareImage(data); 

     } 
    }); 

    return itemView; 
} 



public void shareImage(int data) { 
    Bundle params = new Bundle(); 
     params.putString("name", "Facebook SDK for Android"); 
     params.putString("caption", "Build great social apps and get more installs."); 
     params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps."); 
     params.putString("link", "https://developers.facebook.com/android"); 
     params.putInt("picture", data); 

     WebDialog feedDialog = (
      new WebDialog.FeedDialogBuilder(context, 
       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(context, 
           "Posted story, id: "+postId, 
           Toast.LENGTH_SHORT).show(); 
         } else { 
          // User clicked the Cancel button 
          Toast.makeText(context, 
           "Publish cancelled", 
           Toast.LENGTH_SHORT).show(); 
         } 
        } else if (error instanceof FacebookOperationCanceledException) { 
         // User clicked the "x" button 
         Toast.makeText(context, 
          "Publish cancelled", 
          Toast.LENGTH_SHORT).show(); 
        } else { 
         // Generic, ex: network error 
         Toast.makeText(context, 
          "Error posting story", 
          Toast.LENGTH_SHORT).show(); 
        } 
       } 



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

} 

回答

0

使用飼料對話框或飼料Graph API無法傳遞picture中的圖像數據。所以你應該提供一個url而不是數據。

只是一個把戲 - 你可以先使用/photos上傳一張圖片,在那裏你可以使用圖片數據,然後你可以使用這個圖片的網址到飼料。

跳過它的幫助。祝你好運!

相關問題