android facebook publish photo

后端 未结 1 1341
故里飘歌
故里飘歌 2020-12-29 00:31

After looking on the net for 2 days I finally decided to post on SO.

Well I simply want to publish a photo in my android app on to facebook.

AM using the off

相关标签:
1条回答
  • 2020-12-29 01:19

    Take a look at this.

    Looking for android Facebook SDK examples

    EDIT: Just got this working. This is in the ShareOnFacebook class under the postToWall() function.

    byte[] data = null;
    
    Bitmap bi = BitmapFactory.decodeFile(photoToPost);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    data = baos.toByteArray();
    
    Bundle params = new Bundle();
    params.putString("method", "photos.upload");
    params.putByteArray("picture", data);
    
    AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
    mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null);
    

    EDIT:

    When making the Intent:

    result is the path to the image on the device.

    Intent postOnFacebookWallIntent = new Intent(getApplicationContext(), ShareOnFacebook.class);
    postOnFacebookWallIntent.putExtra("facebookMessage", facebookMessage);
    postOnFacebookWallIntent.putExtra("facebookPhoto", result);
    startActivity(postOnFacebookWallIntent);
    
    0 讨论(0)
提交回复
热议问题