I'm using Facebook 4.0 to share photos through my app but I'm unable to share photos from my phone. I can share an image from the internet by providing it's url but it doesn't work for an image from the phone. The code I'm using for sharing is below.
public void sharePhoto(Uri contentUri, String contentTitle, Bitmap image, String contentDescription){
ShareDialog facebookDialog = new ShareDialog(getActivity());
ShareLinkContent.Builder content = new ShareLinkContent.Builder();
content.setContentUrl(contentUri);
content.setContentTitle(contentTitle);
content.setImageUrl(getImageUri(getActivity(), image));
content.setContentDescription(contentDescription);
ShareLinkContent shareContent = content.build();
facebookDialog.show(shareContent);
}
public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
return Uri.parse(path);
}
I know I can share a bitmap from the phone using the following
public void shareImage(Bitmap image){
ShareDialog facebookDialog = new ShareDialog(getActivity());
SharePhoto photo = new SharePhoto.Builder().setBitmap(image).build();
SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build();
facebookDialog.show(content);
}
However this code requires that the native facebook app be installed on the phone. Is there some way to share a bitmap without having the native app installed.