how to hide app name from Facebook wall post - android

I have registered an app on my Facebook account, And I am posting Photos from app to Facebook wall post, So It's showing shared via "XYZApp". So I want to remove/hide app name from post.
Check Attachment
I have Used
SharePhoto photo = new SharePhoto.Builder().setBitmap(bm).build();
SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build();

Setup ContentProvider :
<provider android:authorities="com.facebook.app.FacebookContentProvider{APP_ID}"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
Then add SharePhotoContent Model into content.
public void dialogShare(Bitmap imagePath){
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(imagePath)
.setCaption("StudyTutorial")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
}
Also to share link content use below method :
public static void shareMessageOnFacebook(Activity activity, CallbackManager
callbackManager, String msg) {
LoginManager.getInstance().registerCallback(callbackManager, new
FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
L.e("FacebookError", loginResult.toString());
if (loginResult.getAccessToken() != null) {
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("app url"))
.setQuote(msg)
.build();
ShareDialog.show(activity, content);
}
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException exception) {
L.e("FacebookError", exception.getMessage());
}
});
LoginManager.getInstance().logInWithReadPermissions(activity, Arrays.asList("public_profile", "email"));
}

Related

Unable to share photo in Facebook

I am taking a photo using an Android phone, and I want to post it in Facebook. My code:
private void SharePhotoFacebook(Bitmap bmp) {
FacebookSdk.sdkInitialize(FaceActivity.this);
// Create a callbackManager to handle the login responses.
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bmp)
.build();
if(ShareDialog.canShow(SharePhotoContent.class)){
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
}
// this part is optional
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
Log.i("David", "Éxito");
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException error) {
Log.i("David", "Error");
}
});
}
But no dialog is showing, and nothing is posted in Facebook. I have implemented this code in the same Activity I take photo (FaceActivity), and is the Activity declared in Facebook Developer page of the app. What is wrong?
I can see like something tries to show (a grey "flash" that appears in the screen) but nothing shows.
EDIT: Im taking photo this way:
makePhoto.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
mCameraSource.takePicture(null, new CameraSource.PictureCallback() {
#Override
public void onPictureTaken(#NonNull byte[] bytes) {
Log.i("David", String.valueOf(bytes.length));
bmp= BitmapFactory.decodeByteArray(bytes,0,bytes.length);
ShowShareDialog();
//SharePhotoFacebook(bmp);
}
});
}
});
I just realized I have this in my debug:
Unsupported get request. Object with ID 'XXXXXXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api [extra]:

Facebook Posted image shared link not working?

When we post image on facebook by my android app it's post successfully but when we click on that post on Facebook app (on mobile devices) there is a toast appear "There's a problem opening this app." but when open in WEB and click on that posted image it'll redirect to shared link successfully.
I have use this code to share post on facebook.
GraphRequest request = GraphRequest.newPostRequest(AccessToken.getCurrentAccessToken(),
"me/feed", null, new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
Log.i(TAG, response.toString());
//checkPostStatusAndEnableButton();
}
});
Bundle postParams = request.getParameters();
postParams.putString("link",post_url);
postParams.putString("caption", caption);
request.setParameters(postParams);
request.executeAsync();
Is we have use some other action for url for mobile devices?
Try this on :
private static List<String> PERMISSIONS = Arrays.asList("public_profile","user_photos","user_videos", "email","user_likes","user_posts",
"user_hometown", "user_location","user_about_me","user_birthday",
"user_friends","user_relationship_details");
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
// App code
Log.i(TAG,"onSuccess registerCallback");
}
#Override
public void onCancel() {
// App code
Log.i(TAG,"onCancel registerCallback");
}
#Override
public void onError(FacebookException exception) {
// App code
Log.i(TAG,"onError registerCallback");
}
});
Then call this share link method :
private void shareLink() {
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("https://developers.facebook.com"))
.build();
ShareDialog shareDialog = new ShareDialog(this);
shareDialog.show(content, ShareDialog.Mode.AUTOMATIC);
}

Post On Facebook Wall With Android

how to share post on wall from facebook sdk 4.10.0 in android?
List<String> permissionNeeds = Arrays.asList("publish_actions");
manager = LoginManager.getInstance();
manager.logInWithPublishPermissions(this, permissionNeeds);
manager.registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
}
#Override
public void onCancel() {
System.out.println("onCancel");
}
#Override
public void onError(FacebookException exception) {
System.out.println("onError");
}
});
I'm Working With This Code...
use this code.
shareDialog = new ShareDialog(this);
callbackManager = CallbackManager.Factory.create();
shareDialog.registerCallback(callbackManager, new
FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
Toast.makeText(getApplicationContext(),"Success",Toast.LENGTH_SHORT).show();
}
#Override
public void onCancel() {
Toast.makeText(getApplicationContext(),"Not Success",Toast.LENGTH_SHORT).show();
}
#Override
public void onError(FacebookException error) {}
});
if (ShareDialog.canShow(ShareLinkContent.class)) {
//Post Link with Detail On Wall....
/* ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle("Hello Facebook")
.setContentDescription("The 'Hello Facebook' sample showcases simple Facebook integration")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();*/
//Post Image on Wall...........
Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.naturals1);
SharePhoto photo = new SharePhoto.Builder().setBitmap(image).build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
}

have publish_actions approved but facebook post not public

My android application have publish_actions submission were approved but when I post photo on facebook via my application It's not public post because my friend on facebook cannot see this that post.
final String hashTagPost = hashtag;
callbackManager = CallbackManager.Factory.create();
List<String> permissionNeeds = Arrays.asList("publish_actions"); //I added publish_actions
loginManager = LoginManager.getInstance();
loginManager.logInWithPublishPermissions(this, permissionNeeds);
loginManager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bitmap)
.setCaption(txtCaption.getText().toString() + " #EventPocket " + hashTagPost)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content, null);
Toast.makeText(PhotoActivity.this, "Post Success", Toast.LENGTH_SHORT).show();
finish();
dialog.dismiss();
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException e) {
}
}
This a part of my application.
What I do it more?

Facebook API add message to SharePhotoContent

I want to share a picture on Facebook with a description but I only can post an image without description. How can I add a message/description to the photo?
The code I am using to share:
SharePhoto photo = new SharePhoto.Builder().setBitmap(shareBitmap).build();
ArrayList<SharePhoto> photos = new ArrayList<>();
photos.add(photo);
SharePhotoContent.Builder shareContentBuilder = new SharePhotoContent.Builder();
shareContentBuilder.addPhotos(photos);
SharePhotoContent sharePhotoContent = shareContentBuilder.build();
ShareApi.share(sharePhotoContent, new FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException e) {
}
});
Found the solution. I had to add .setCaption("Caption") to the SharePhoto Builder.

Categories

Resources