在android 3.0中从sdcard发送facebook 3.0墙上的图像?

时间:2013-08-06 05:22:59

标签: android facebook image send

我正在使用发布供稿对话框将文本和图像从SD卡发送到Facebook墙 我使用facebook sdk 3.0文本成功发送到Facebook墙,但图像不发送 我把我的代码放在这里你可以看看

  

pickimage.java

private void publishFeedDialog()
    {

        Bitmap bmp = BitmapFactory.decodeFile("/mnt/sdcard/abc.jpg");        
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);  // where bm is bitmap from Sdcard
        byte[] byteArray = stream.toByteArray();


        Bundle params = new Bundle();
        params.putString("name","abcd");
        params.putByteArray("source",byteArray);

        final 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(SearchListClickActivity.this,"Posted story, id: "+postId,Toast.LENGTH_SHORT).show();
                        } 
                        else
                        {
                            // User clicked the Cancel button
                         // Toast.makeText(this.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(getActivity().getApplicationContext(),"Error posting story",Toast.LENGTH_SHORT).show();
                    }
                }

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

0 个答案:

没有答案