2013-03-14 20 views
1

我想在Facebook上发布带有消息和我的应用程序名称的图片。我的文章必须是这样的:如何在Facebook上发布图片和邮件时获得完美对齐

enter image description here

我已经申请下面的代码

Bitmap bi = BitmapFactory.decodeResource(getResources(), R.drawable.bluerib); 

ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
bi.compress(Bitmap.CompressFormat.JPEG,100, baos); 
data = baos.toByteArray(); 

Bundle params = new Bundle(); 
params.putByteArray("picture", data); 
params.putString("method", messageToPost); 

facebook.request("me"); 
String response = facebook.request("me/photos", params, "POST"); 

我successfuly可以在Facebook上同时发送图像和按摩除了应用程序的名称,但我要发布它在Facebook的墙上,我的照片不能保存在Facebook的照片,我想要左侧的图像完美对齐,然后应用程序名称顶部和我的消息。如何做到这一点,我必须为此使用图形API吗?如果是,如何使用它?如果没有,请提供给我解决方案。

回答

2

这里我是如何做到的。

private void publishFeedDialog() { 
     System.out.println("Working"); 
     Bundle postParams = new Bundle(); 
     postParams.putString("name", "I am an Engineer"); 
     postParams.putString("caption", 
       "Working very heard to make things work."); 
     postParams 
       .putString("description", 
         "This project is killing me, Still I am trying, and finally I got success."); 
     postParams.putString("link", "http://www.kodebusters.com"); 
     postParams 
       .putString(
         "picture", 
         "http://cdn1.iconfinder.com/data/icons/iconslandsport/PNG/128x128/Soccer_Ball.png"); 

     new MYasync(postParams).execute(); 

    } 

通过例外

class MYasync extends AsyncTask<Void, Void, Void> { 

      Bundle params; 
      private String res; 

      public MYasync(Bundle params) { 
       super(); 
       this.params = params; 
      } 

      @Override 
      protected void onPostExecute(Void result) { 
       System.out.println(res); 
       super.onPostExecute(result); 
      } 

      @Override 
      protected Void doInBackground(Void... pp) { 
       try { 
        res = facebook.request("me/feed", params, "POST"); 

       } catch (FileNotFoundException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } catch (MalformedURLException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } catch (IOException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 
       return null; 
      } 

     } 
+0

它就像一个charm.Thanks.great帮助运行上的AsyncTask您的网络电话,或者可能! – 2013-03-17 03:25:05

相关问题