I am new to the Android development. I want to Share Image/ Photo from the Drawable folder to the Facebook App by using the Facebook SDK 4.1.0 . I am using the Facebook ShareDialog. For sharing i am using the ShareLinkContent API as well as ShareOpenGraphContent with the existing book object open graph story. I am unable to share the image/photo from the drawable folder. If anyone having solution for the same problem then post.
Below is the code for the ShareLinkContent :
LoginManager.getInstance().registerCallback(mCallbackManager,newFacebookCallback<LoginResult>(){@Overridepublicvoid onSuccess(LoginResult loginResult){
AccessToken accessToken = loginResult.getAccessToken();Log.i("accessToken +++++++++",accessToken.getToken());
if(ShareDialog.canShow(ShareLinkContent.class)){
ShareLinkContent linkContent =newShareLinkContent.Builder().setContentTitle(titleText).setContentDescription(descriptionText).setImageUrl(Uri.fromFile(FileObject)).setContentUrl(Uri.parse("https://www.facebook.com/"+ loginResult.getAccessToken())).build();
shareDialog.show(linkContent);
}}
@Overridepublicvoid onCancel(){
getLayout(R.layout.layout_second);Log.d("On Cancel","On cancel");}
@Overridepublicvoid onError(FacebookException error){Log.d("Error", error.toString());}});
I want to post the Image/ photo/ music/ video/ animation file from the application to the Facebook API. But even if i pass the File Object in the Url still it asking for the image from the "http:// or https:// from the web". Please suggest if anyone having solution on it
Below is the code for the ShareLinkContent :
LoginManager.getInstance().registerCallback(mCallbackManager,newFacebookCallback<LoginResult>(){@Overridepublicvoid onSuccess(LoginResult loginResult){
AccessToken accessToken = loginResult.getAccessToken();Log.i("accessToken +++++++++",accessToken.getToken());
if(ShareDialog.canShow(ShareLinkContent.class)){
ShareLinkContent linkContent =newShareLinkContent.Builder().setContentTitle(titleText).setContentDescription(descriptionText).setImageUrl(Uri.fromFile(FileObject)).setContentUrl(Uri.parse("https://www.facebook.com/"+ loginResult.getAccessToken())).build();
shareDialog.show(linkContent);
}}
@Overridepublicvoid onCancel(){
getLayout(R.layout.layout_second);Log.d("On Cancel","On cancel");}
@Overridepublicvoid onError(FacebookException error){Log.d("Error", error.toString());}});
I want to post the Image/ photo/ music/ video/ animation file from the application to the Facebook API. But even if i pass the File Object in the Url still it asking for the image from the "http:// or https:// from the web". Please suggest if anyone having solution on it