Android Facebook Share ,Description not showing - android

I am using facebook sdk for sharing on facebook.
My code is below,it's working fine.But when i want to change the content url to Application playstore link then content description is not showing into facebook.
Is there any solution or i am making stupid mistake ?
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(AppConstant.RESTURENT_NAME)
.setContentDescription("Hi,You should check out Bangkok Eatery.")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();
shareDialog.show(linkContent);
}

ShareDialog shareDialog = new ShareDialog(this);
CallbackManager callbackManager = CallbackManager.Factory.create();
shareDialog.registerCallback(callbackManager, new
FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException error) {
}
});
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(getString(R.string.app_name))
.setContentDescription("")
.setContentUrl(Uri.parse("your link"))
.build();
shareDialog.show(linkContent);

FacebookSdk initialize in onCreate method
CallbackManager callbackManager;
ShareDialog shareDialog;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
// this part is optional
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { ... });
}
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(AppConstant.RESTURENT_NAME)
.setContentDescription("Hi,You should check out Bangkok Eatery.")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();
shareDialog.show(linkContent);
}

Related

how to hide app name from Facebook wall post

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"));
}

How to Check Facebook invite app to friends is successfully sent invitation or not sent in android [duplicate]

In the new Fb SDK 4.0 for Android you can register a callback for the LoginButton according to the docs. https://developers.facebook.com/docs/facebook-login/android/v2.3
The question is is this possible for the AppInviteDialog as well? Or is there any other way to identify if the App-Invite was successful or not?
Yes, this is possible.
public static void openDialogInvite(final Activity activity)
{
String appLinkUrl, previewImageUrl;
appLinkUrl = "your app link url";
previewImageUrl = "https://www.example.com/my_invite_image.jpg";
if (AppInviteDialog.canShow())
{
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl)
.setPreviewImageUrl(previewImageUrl)
.build();
AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
CallbackManager sCallbackManager = CallbackManager.Factory.create();
appInviteDialog.registerCallback(sCallbackManager, new FacebookCallback<AppInviteDialog.Result>()
{
#Override
public void onSuccess(AppInviteDialog.Result result)
{
}
#Override
public void onCancel()
{
}
#Override
public void onError(FacebookException e)
{
}
});
appInviteDialog.show(content);
}
}

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?

Categories

Resources