Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with Facebook request in Android

I'm using facebook-android-sdk to post messages to my wall.

The following request:

Bundle params = new Bundle();

params.putString("message", "test message");

mAsyncRunner = new AsyncFacebookRunner(mFacebook);
mAsyncRunner.request("me/feed", params, "POST", new PostRequestListener(), null);  

returns the warnings shown below, although the message is shown correctly on the wall.

When converting the message to bytes, as seen in similar questions on Stackoverflow:

params.putByteArray("message", "test message".Bytes());

there is no more warnings for Key message, and the post is shown on the Facebook wall, but with no message.

What's wrong?

Thanks.

Warnings:

03-14 11:35:01.635: WARN/Bundle(9963): Key message expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-14 11:35:01.675: WARN/Bundle(9963): Attempt to cast generated internal exception:
03-14 11:35:01.675: WARN/Bundle(9963): java.lang.ClassCastException: java.lang.String
03-14 11:35:01.675: WARN/Bundle(9963):     at android.os.Bundle.getByteArray(Bundle.java:1305)
03-14 11:35:01.675: WARN/Bundle(9963):     at com.facebook.android.Util.encodePostBody(Util.java:63)
03-14 11:35:01.675: WARN/Bundle(9963):     at com.facebook.android.Util.openUrl(Util.java:182)
03-14 11:35:01.675: WARN/Bundle(9963):     at com.facebook.android.Facebook.request(Facebook.java:559)
03-14 11:35:01.675: WARN/Bundle(9963):     at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
03-14 11:35:01.685: WARN/Bundle(9963): Key method expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-14 11:35:01.725: WARN/Bundle(9963): Attempt to cast generated internal exception:
03-14 11:35:01.725: WARN/Bundle(9963): java.lang.ClassCastException: java.lang.String
03-14 11:35:01.725: WARN/Bundle(9963):     at android.os.Bundle.getByteArray(Bundle.java:1305)
03-14 11:35:01.725: WARN/Bundle(9963):     at com.facebook.android.Util.encodePostBody(Util.java:63)
03-14 11:35:01.725: WARN/Bundle(9963):     at com.facebook.android.Util.openUrl(Util.java:182)
03-14 11:35:01.725: WARN/Bundle(9963):     at com.facebook.android.Facebook.request(Facebook.java:559)
03-14 11:35:01.725: WARN/Bundle(9963):     at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
03-14 11:35:01.735: WARN/Bundle(9963): Key access_token expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-14 11:35:01.775: WARN/Bundle(9963): Attempt to cast generated internal exception:
03-14 11:35:01.775: WARN/Bundle(9963): java.lang.ClassCastException: java.lang.String
03-14 11:35:01.775: WARN/Bundle(9963):     at android.os.Bundle.getByteArray(Bundle.java:1305)
03-14 11:35:01.775: WARN/Bundle(9963):     at com.facebook.android.Util.encodePostBody(Util.java:63)
03-14 11:35:01.775: WARN/Bundle(9963):     at com.facebook.android.Util.openUrl(Util.java:182)
03-14 11:35:01.775: WARN/Bundle(9963):     at com.facebook.android.Facebook.request(Facebook.java:559)
03-14 11:35:01.775: WARN/Bundle(9963):     at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
03-14 11:35:01.785: WARN/Bundle(9963): Key format expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-14 11:35:01.825: WARN/Bundle(9963): Attempt to cast generated internal exception:
03-14 11:35:01.825: WARN/Bundle(9963): java.lang.ClassCastException: java.lang.String
03-14 11:35:01.825: WARN/Bundle(9963):     at android.os.Bundle.getByteArray(Bundle.java:1305)
03-14 11:35:01.825: WARN/Bundle(9963):     at com.facebook.android.Util.encodePostBody(Util.java:63)
03-14 11:35:01.825: WARN/Bundle(9963):     at com.facebook.android.Util.openUrl(Util.java:182)
03-14 11:35:01.825: WARN/Bundle(9963):     at com.facebook.android.Facebook.request(Facebook.java:559)
03-14 11:35:01.825: WARN/Bundle(9963):     at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
like image 600
jul Avatar asked Mar 14 '11 10:03

jul


1 Answers

It's a bug in facebook's SDK, see this answer for a fix.

like image 189
Hokascha Avatar answered Sep 20 '22 16:09

Hokascha