Android プロジェクトの drawable フォルダーから 1 つの画像を Facebook の壁にアップロードしようとしています。しかし、私は失敗しました...メッセージは壁に表示されていますが、画像は壁にありません..サンプルコードを以下に示します..
Drawable drawable = ClassName.this.getResources().getDrawable(R.drawable.ic_launcher);
Bitmap bitmap = (Bitmap)((BitmapDrawable) drawable).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] bitMapData = stream.toByteArray();
Bundle params = new Bundle();
params.putString("message", "Tarun Kumar");
params.putString("name", "MY Image");
params.putByteArray("picture", bitMapData);
mAsyncFbRunner.request("me/feed", params, "POST", new WallPostListener());
ログにいくつかのエラーが表示されています..のように
10-03 12:55:55.664: W/Bundle(529): Key message expected byte[] but value was a java.lang.String. The default value <null> was returned.
10-03 12:55:55.914: D/dalvikvm(529): GC_FOR_MALLOC freed 6599 objects / 465168 bytes in 225ms
10-03 12:55:55.924: W/Bundle(529): Attempt to cast generated internal exception:
10-03 12:55:55.924: W/Bundle(529): java.lang.ClassCastException: java.lang.String
10-03 12:55:55.924: W/Bundle(529): at android.os.Bundle.getByteArray(Bundle.java:1305)
10-03 12:55:55.924: W/Bundle(529): at com.facebook.android.Util.openUrl(Util.java:155)
10-03 12:55:55.924: W/Bundle(529): at com.facebook.android.Facebook.request(Facebook.java:559)
10-03 12:55:55.924: W/Bundle(529): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:208)
10-03 12:55:55.924: W/Bundle(529): Key format expected byte[] but value was a java.lang.String. The default value <null> was returned.
10-03 12:55:55.924: W/Bundle(529): Attempt to cast generated internal exception:
10-03 12:55:55.924: W/Bundle(529): java.lang.ClassCastException: java.lang.String
10-03 12:55:55.924: W/Bundle(529): at android.os.Bundle.getByteArray(Bundle.java:1305)
10-03 12:55:55.924: W/Bundle(529): at com.facebook.android.Util.openUrl(Util.java:155)
10-03 12:55:55.924: W/Bundle(529): at com.facebook.android.Facebook.request(Facebook.java:559)
10-03 12:55:55.924: W/Bundle(529): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:208)
10-03 12:55:55.984: W/Bundle(529): Key access_token expected byte[] but value was a java.lang.String. The default value <null> was returned.
10-03 12:55:55.984: W/Bundle(529): Attempt to cast generated internal exception:
10-03 12:55:55.984: W/Bundle(529): java.lang.ClassCastException: java.lang.String
10-03 12:55:55.984: W/Bundle(529): at android.os.Bundle.getByteArray(Bundle.java:1305)
10-03 12:55:55.984: W/Bundle(529): at com.facebook.android.Util.openUrl(Util.java:155)
10-03 12:55:55.984: W/Bundle(529): at com.facebook.android.Facebook.request(Facebook.java:559)
10-03 12:55:55.984: W/Bundle(529): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:208)
10-03 12:55:55.984: D/webviewglue(529): nativeDestroy view: 0x27a548
10-03 12:55:56.014: W/Bundle(529): Key name expected byte[] but value was a java.lang.String. The default value <null> was returned.
10-03 12:55:56.014: W/Bundle(529): Attempt to cast generated internal exception:
10-03 12:55:56.014: W/Bundle(529): java.lang.ClassCastException: java.lang.String
10-03 12:55:56.014: W/Bundle(529): at android.os.Bundle.getByteArray(Bundle.java:1305)
10-03 12:55:56.014: W/Bundle(529): at com.facebook.android.Util.openUrl(Util.java:155)
10-03 12:55:56.014: W/Bundle(529): at com.facebook.android.Facebook.request(Facebook.java:559)
10-03 12:55:56.014: W/Bundle(529): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:208)