Reputation: 1939
Ok so I have setup a new Facebook app and I have the API and all that jazz setup also and have made successful posts to Facebook using the API. Here is my issue.
How do I format the text the way I want too??
For example:
description += "First line \r\n";
description += "Second line \r\n";
I am using the Facebook Android SDK and using the Feed Dialog approach as listed here
Also, I am using the feed dialog like so:
String description += "First line \r\n";
description += "Second line \r\n";
Facebook facebook = new Facebook("MY_APP_ID");
SetAccessToken(mContext, facebook);
params.putString("link", "");
params.putString("picture", "");
params.putString("name", "");
facebook.dialog(mContext, "feed", params, new Facebook.DialogListener() {
public void onFacebookError(FacebookError e) {
}
public void onError(DialogError e) {
}
public void onComplete(Bundle values) {
}
public void onCancel() {
}
});
Whenever, I do that it pulls up my Facebook dialog and the lines are not separated by line feeds. I also tried to use HTML such as
<p>Line 1</p>
<p>Line 2</p>
My guess is that I need to use another method in order to actually post formatted text, other than the feed dialog. I know that other Facebook apps are posting to users feeds with properly formatted text. Just not sure why the SDK doesn't offer the same functionality.
EDIT 1
Just to add this, the submission is actually in a URL format at the end anyway. I tried adding URL escape characters but that didn't seem to do anything for me.
String url = endpoint + "?" + Util.encodeUrl(parameters);
Then they pass that into a webview. So I am currently looking into this. Any advice is appreciated.
Upvotes: 0
Views: 1542
Reputation: 2065
Have you tried:
String message = "<p>Line 1</p><p>Line 2</p>";
params.putString("message", Html.fromHtml(message).toString());
Upvotes: 1
Reputation:
as far as I have researched...facebook doesn't allow it's domain image to be posted on wall through post. So, we can't use it. Now what I am doing is getting the imge through following code:
ImageView user_picture;
user_picture = (ImageView) findViewById(R.id.user_picture);
URL img_value = null;
Bitmap mIcon1 = null;
try {
img_value = new URL("http://graph.facebook.com/XXXX/picture");
try {
mIcon1 = BitmapFactory.decodeStream(img_value
.openConnection().getInputStream());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(mIcon1!=null){
user_picture.setImageBitmap(mIcon1);
}
if you want it to convert to byte array
ByteArrayOutputStream baos = new ByteArrayOutputStream();
mIcon1.compress(Bitmap.CompressFormat.PNG, 100, baos);
b = baos.toByteArray();
Sending this image to my server and then posting to wall.
Upvotes: 2