2012-08-16 57 views

回答

0

如果你熟悉的Facebook SDK爲Android,試試這個:

//Getting the image 
    Bitmap bm = theImageViewToUpload.getDrawingCache(); 
    byte[] bArray = null; 
    ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); 
    bm.compress(Bitmap.CompressFormat.JPEG, 100, baoStream); 
    bArray = baoStream.toByteArray(); 

    Bundle bund = new Bundle(); 
    bund.putString(Facebook.TOKEN, access_token); 
    bundle.putString("caption", "This is your image-caption on Facebook"); 
    bund.putByteArray("picture", bArray); 

    //Uploading to Facebook 
    try { 
     fb.request("me/photos", bund, "POST"); 
    } catch (FileNotFoundException e) { 
     e.printStackTrace(); 
    } catch (MalformedURLException e) { 
     e.printStackTrace(); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 

如果你不熟悉Facebook的SDK,我不是在這裏教你一個答案的一切計劃,但看看他們的參考:http://developers.facebook.com/docs/reference/androidsdk/

編輯:將此代碼添加到您打算使用的按鈕的onClick。

+0

好吧,我會嘗試它!非常感謝! :) – imtheuser 2012-08-20 15:55:37

相關問題