سؤال

Im developing an android application which will upload and share a photo from my app to my facebook timeline, how can i do this? See image :

enter image description here

I've been taking too much time reading the facebook docs, but found no luck, also i tried this very useful library by Mr. Roman Kushnarenko from git hub, but it doesn't support the upload via dialog. can you help me guys? Thanks :)

هل كانت مفيدة؟

المحلول

Currently by using android-simple-facebook library you can upload a photo to your facebook timeline without using dialog.

This is how you can achieve this: Set OnPublishListener and call for publish(Photo, OnPublishListener).

// create publish listener
OnPublishListener onPublishListener = new SimpleFacebook.OnPublishListener()
{

    @Override
    public void onFail(String reason)
    {
        // insure that you are logged in before publishing
        Log.w(TAG, reason);
    }

    @Override
    public void onException(Throwable throwable)
    {
        Log.e(TAG, "Bad thing happened", throwable);
    }

    @Override
    public void onThinking()
    {
        // show progress bar or something to the user while publishing
        Log.i(TAG, "In progress");
    }

    @Override
    public void onComplete(String id)
    {
        Log.i(TAG, "Published successfully. id = " + id);
    }
};

// This is the image you want to upload
Bitmap bitmap = ...

// create Photo instance and add some properties
Photo photo = new Photo(bitmap);
photo.addDescription("Screenshot from #android_simple_facebook sample application");
photo.addPlace("110619208966868");

// publish photo to app album
mSimpleFacebook.publish(photo, onPublishListener);

Don't forget to set PERMISSIONS.PUBLISH_STREAM in your configuration. See: configuration part

Publishing photo by using dialog will be pushed soon to the master branch. I will update this answer to this question, once it will be pushed.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top