我有以下代码上传照片...
byte[] data = null;
Bundle params = new Bundle();
Bitmap bitmap = getBitmapFromURL("http://aux.iconpedia.netuploads/250578763.png");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
params.putString("method", "photos.upload");
params.putByteArray("picture", data);
Logcat是::
11-04 22:48:57.535: WARN/Bundle(424): Key picture expected String but value was a [B. The default value <null> was returned.
11-04 22:48:57.555: WARN/Bundle(424): Attempt to cast generated internal exception:
11-04 22:48:57.555: WARN/Bundle(424): java.lang.ClassCastException: [B
11-04 22:48:57.555: WARN/Bundle(424): at android.os.Bundle.getString(Bundle.java:1040)
11-04 22:48:57.555: WARN/Bundle(424): at com.logistics.finalfacebook.Util.encodeUrl(Util.java:85)
11-04 22:48:57.555: WARN/Bundle(424): at com.logistics.finalfacebook.Facebook.dialog(Facebook.java:622)
11-04 22:48:57.555: WARN/System.err(424): java.lang.NullPointerException
11-04 22:48:57.565: WARN/System.err(424): at java.net.URLEncoder.encode(URLEncoder.java:53)
11-04 22:48:57.565: WARN/System.err(424): at com.logistics.finalfacebook.Util.encodeUrl(Util.java:85)
11-04 22:48:57.565: WARN/System.err(424): at com.logistics.finalfacebook.Facebook.dialog(Facebook.java:622)
11-04 22:48:57.565: WARN/System.err(424): at com.logistics.finalfacebook.MainActivity$LoginDialogListener.onComplete(MainActivity.java:245)
11-04 22:48:57.565: WARN/System.err(424): at com.logistics.finalfacebook.Facebook$1.onComplete(Facebook.java:316)
11-04 22:48:57.565: WARN/System.err(424): at com.logistics.finalfacebook.FbDialog$FbWebViewClient.shouldOverrideUrlLoading(FbDialog.java:134)
答案 0 :(得分:1)
在第622行的Facebook.java
中,您正在使用空字符串调用Util.java
的{{1}}。
这是您使用它的方式:
encodeUrl()