Cant see full content when wallpost using facebook sdk - android

Iam using following method to make a wall post using facebook sdk 3+ . After posting the story, I noticed that there is no complete content posted.About Half of it is missing.
Is there any workaround for this, or do I have to go for another method?
public void postToWall() {
// post on user's wall.
Bundle params = new Bundle();
params.putString("name", "Title");
params.putString("description", fbText);// The contents here are missing.
facebook.dialog(this, "feed",params, new DialogListener() {
#Override
public void onFacebookError(FacebookError e) {
}
#Override
public void onError(DialogError e) {
}
#Override
public void onComplete(Bundle values) {
}
#Override
public void onCancel() {
}
});
}

I see it's a common problem among Facebook SDKs
https://stackoverflow.com/questions/15761737/description-is-trunctuated-when-i-post-desctription-from-ios-using-facebook-sdk
Someone try to workaround this issue putting the text in the caption value instead of description

Related

Facebook MessageDialog doesn't open Android

I'm trying to make it possible for people to send a link to one of their friends, I'm using the facebook API. The problem is that the send dialog doesn't show up, when I try to make a share dialog however it opens without any problem.
This is my code (it is set in a listadapter because in the list are different items that have the send_button (which is a normal button)):
CallbackManager callbackManager = CallbackManager.Factory.create();
final MessageDialog messageDialog = new MessageDialog((Activity)context);
messageDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
Log.e("test", "send success");
}
#Override
public void onCancel() {
Log.e("test", "send cancel");
}
#Override
public void onError(FacebookException e) {
Log.e("test", "send error");
}
});
send_button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Log.d("test","clicked");
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Test")
.setContentDescription("heytest")
.build();
messageDialog.show(linkContent);
}
});
The context is what is given through from the mainactivity. I don't get why it isn't working I've also overwritten the onActivityResult() method in the mainactivity.
I would appreciate some help, thanks.

Posting a Text Status using Facebook API in Android - The simplest method

I have been searching a lot to find a way to do this. But nothing seems to be working for me. Can someone please help in doing this?
This is my image button for facebook status post:
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/hoributtons"
android:layout_alignTop="#+id/imageButton2"
android:background="#00000000"
android:contentDescription="#string/facebook"
android:onClick="shareOnFacebook"
android:src="#drawable/facebookbutton" />
This is my mainactivity.java file's corresponding part:
public class MainActivity extends FacebookActivity {
private static final String APP_ID = "xxxxxxxxxxxxx";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void shareOnFacebook(View v) {
//mfacebook = new Facebook("xxxxxxxxxxxxx");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Can someone point in the right direction? :)
Assuming that you want to post on your own wall (since the question is not clear), this should work for you.
public class MainActivity extends Activity {
private static final String APP_ID = "xxxxxxxxxxxxx";
private Facebook mFacebook;
private AsyncFacebookRunner mAsyncRunner;
private EditText yourEditText;
private String toShare;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mFacebook = new Facebook();
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
SessionEvents.addAuthListener(new SampleAuthListener());
SessionEvents.addLogoutListener(new SampleLogoutListener());
yourEditText = (EditText) findViewById(R.id.<youreditTextId>);
toShare = yourEditText.getText().toString();
}
public void shareOnFacebook(View v) {
Bundle params = new Bundle();
params.putString("message", toShare);
mAsyncRunner.request("me/feed", params, "POST", new RequestListener() {
public void onMalformedURLException(MalformedURLException e) {}
public void onIOException(IOException e) {}
public void onFileNotFoundException(FileNotFoundException e) {}
public void onFacebookError(FacebookError e) {}
public void onComplete(String response) {
}
});
Toast.makeText(MainActivity.this, "Posting to your Wall", Toast.LENGTH_SHORT).show();
}
}
For details on posting pictures to wall, Facebook has a good documentation.
The simplest way to post message on user`s wall who is successfully login using your android application is(my working code)_
public class AndroidFacebookWallPost extends Activity {
// Your Facebook APP ID:
private static String APP_ID = "your App ID here"; //
// Instance of Facebook Class:
private Facebook facebook;
private AsyncFacebookRunner mAsyncRunner;
// Your ImageButton that Post Message to Facebook Wall:
ImageButton btnPostToWall;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnPostToWall = (ImageButton) findViewById(R.id.imageButton1);// Your image button...
facebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(facebook);
// set listener for Post Message button
btnPostToWall.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
postToWall();
}
});
}
/**
* Method that Post a Text Status using Facebook API on user`s wall.
*/
public void postToWall() {
// post on user's wall.
facebook.dialog(this, "feed", new DialogListener() {
#Override
public void onFacebookError(FacebookError error) {
Toast.makeText(AndroidFacebookWallPost.this, "Post fail "+error, Toast.LENGTH_LONG).show();
}
#Override
public void onError(DialogError error) {
Toast.makeText(AndroidFacebookWallPost.this, "Post fail due to "+error, Toast.LENGTH_LONG).show();
}
#Override
public void onComplete(Bundle values) {
Toast.makeText(AndroidFacebookWallPost.this, "Post success.", Toast.LENGTH_LONG).show();
}
#Override
public void onCancel() {
Toast.makeText(AndroidFacebookWallPost.this, "Cancle by user!", Toast.LENGTH_LONG).show();
}
});
}
}
for more please gone through Getting Started with the Facebook SDK for Android.
Here is details of variable that you can out in bundle
Bundle params = new Bundle();
params.putString("message", "This string will appear as the status message");
params.putString("link", "This is the URL to go to");
params.putString("name", "This will appear beside the picture");
params.putString("caption", "This will appear under the title");
params.putString("description", "This will appear under the caption");
params.putString("picture", "This is the image to appear in the post");
And use AsyncFacebookRunner for post data to facebook :
mAsyncRunner.request("me/feed", params, "POST", new RequestListener() {
public void onMalformedURLException(MalformedURLException e) {}
public void onIOException(IOException e) {}
public void onFileNotFoundException(FileNotFoundException e) {}
public void onFacebookError(FacebookError e) {}
public void onComplete(String response) {
}
});

How to Post Status on facebook wall using my own Textview?

I am using facebook defaul dialog to share post on my facebook wall . My code is given below .
facebook.dialog(this, "feed", new DialogListener() {
#Override
public void onFacebookError(FacebookError e) {
}
#Override
public void onError(DialogError e) {
}
#Override
public void onComplete(Bundle values) {
}
#Override
public void onCancel() {
}
});
But now I am adding a TextView and a Button , and after clicking on button the textView text will be posted on my facebook wall.
Override onComplete() in your DialogListener then do what you want or get the value using getText from the textview and post it.
public void onComplete(Bundle values) {
mProgress.setMessage("Posting ...");
mProgress.show();
AsyncFacebookRunner mAsyncFbRunner = new AsyncFacebookRunner(mFacebook);
Bundle params = new Bundle();
params.putString("message", "A Game Developed By Me !");
params.putString("name", "Match Maker");
params.putString("caption", "www.labmimosa.com/");
params.putString("link", "https://play.google.com/store/apps/details?id=com.reverie.fushh");
params.putString("description", "Dexter: Blood. Sometimes it sets my teeth on edge, other times it helps me control the chaos.");
params.putString("picture", "http://twitpic.com/show/thumb/6hqd44");
//params.putByteArray("picture", bitMapData);
mAsyncFbRunner.request("me/feed", params, "POST", new WallPostListener());
}
Wallpostlistener class is
private final class WallPostListener extends BaseRequestListener {
public void onComplete(final String response) {
mRunOnUi.post(new Runnable() {
#Override
public void run() {
mProgress.cancel();
Toast.makeText(Exp_Fb_Twt_Activity.this, "Posted to Facebook", Toast.LENGTH_SHORT).show();
}
});
}
}

android facebook: Not showing info in dialog

I'm trying to open a facebook post dialog when I click on some element. Dialog itself is working well. I could write some comments in the text field and the post could be seen on the website. However I want to add some info the area below the comment, which contains caption, link, picture and so on. I referred to several tutorials to implement this but they didn't work for me. Say, the caption I entered would not be shown in the dialog. The code is like:
mFacebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
dFbPostButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Bundle b = new Bundle();
b.putString("caption","Check This Hotel");
//Result is the class name
//Nothing too much in SampleDialogListener
mFacebook.dialog(Result.this, "feed", b,new SampleDialogListener());
}
}
Any help would be really appreciated!!
Follow the below code
Bundle params = new Bundle();
params.putString("caption", "Mona Lisa");
params.putString("description","The Mona Lisa...");
params.putString("picture","http://tineye.com/images/widgets/mona.jpg");
params.putString("name", "Mona Lisa");
mFacebook.dialog(this, "feed", params, new DialogListener() {
#Override
public void onComplete(Bundle values) {}
#Override
public void onCancel() {}
#Override
public void onError(DialogError de) {}
#Override
public void onFacebookError(FacebookError fbe) {}
});
it ll help

Android - Methods in DialogListener attached to Facebook.authorize() not getting hit

I'm trying to integrate the Facebook Android SDK in my app, but I can't seem to get the most basic authentication working. I've got my project setup, my Facebook App ID, everything as required.
I kick off the Facebook authentication with a simple OnClickListener():
signIn_Facebook.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v)
{
Log.i("MyTag", "Facebook authorize about to start.");
facebook.authorize(SignIn.this, new FacebookLoginDialogListener());
}
});
My problem is that none of the methods in the DialogListener ever get called:
private class FacebookLoginDialogListener implements DialogListener {
public void onComplete(Bundle values)
{
Log.i("MyTag", "Facebook authorize complete.");
}
#Override
public void onFacebookError(FacebookError error) {
Log.i("MyTag", "Facebook authorize facebook error.");
}
#Override
public void onError(DialogError e)
{
Log.i("MyTag", "Facebook authorize dialog error.");
}
#Override
public void onCancel()
{
Log.i("MyTag", "Facebook authorize cancel.");
}
}
When this code runs on the app, the Facebook dialog opens up, you can sign in, and then it just closes - no errors - however none of the log message (or breakpoints) in the FacebookLoginDialogListener class ever get called.
I feel as though I'm missing something really obvious. Thanks...
SOLVED
Just needed to add:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
facebook.authorizeCallback(requestCode, resultCode, data);
}
try this:
private Facebook mFb;
private String[] mPermissions;
mFb.authorize(mActivity, mPermissions, new LoginDialogListener());
If you want an example check out https://github.com/facebook/facebook-android-sdk/blob/master/examples/simple/src/com/facebook/android/LoginButton.java
Anything else, just ask ;)

Categories

Resources