Skip to content
This repository has been archived by the owner on Aug 3, 2019. It is now read-only.

Publish photo

Roman Kushnarenko edited this page Oct 29, 2014 · 2 revisions

Without dialog

You can publish (upload) photo to default album or to any other album you have.
Photo can be created from:

  • Bitmap
  • File
  • byte[]

Initialize callback listener:

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

	/* 
	 * You can override other methods here: 
	 * onThinking(), onFail(String reason), onException(Throwable throwable)
	 */
};

Build photo for publishing:

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

// create Photo instance and add some properties
Photo photo = new Photo.Builder()
	.setImage(bitmap)
	.setName("Screenshot from #android_simple_facebook sample application")
	.setPlace("110619208966868")
	.build();

Publish photo to application (default) album:

mSimpleFacebook.publish(photo, onPublishListener);

Publish photo to specific album:

String albumId = ...;

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

With dialog

You can publish photo or up to 6 photos with dialog.

Important things:

  • You can do it without login ✨
  • You can do it without permissions ✨
  • Currenly only Bitmap is supported
  • setName() and setPrivacy() doesn't matter here, since it can be configured from dialog only
  • You should verify that you have in you manifest <provider>. Read setup project.

Publish one photo

Build photo for publishing:

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

// create Photo instance and add some properties
Photo photo = new Photo.Builder()
	.setImage(bitmap)
	.setPlace("110619208966868")
	.build();

Publish photo with dialog:

mSimpleFacebook.publish(photo, true, onPublishListener);

Publish up to 6 photos

Build photos for publishing:

List<Photo> photos = ...

Publish photos with dialog:

mSimpleFacebook.publish(photos, onPublishListener);
Clone this wiki locally