2012-03-30 6 views
1

folgte ich die Methode Facebook-Status-Updates, ohne ihr Dialogfeld aus dieser Antwort schreiben auf SO: https://stackoverflow.com/a/7528388/450534Android Facebook teilt Auf Wand ohne Dialog Warnungen

I Status-Updates von der Apps Aktivität veröffentlichen kann, aber es ist immer noch zu erzeugen Warnungen.

Es ist eine sehr lange Liste von Warnungen von der DDMS. Irgendwelche Ratschläge zur Behebung des Problems sind willkommen.

Der Code:

protected void postToWall(String message) { 

     if (!Utility.mFacebook.isSessionValid()) { 
      Util.showAlert(this, "Warning", "You must first log in."); 
     } 

     Log.d("Tests", "Testing graph API wall post"); 
     try { 
      String response = Utility.mFacebook.request("me"); 
      Bundle parameters = new Bundle(); 
      parameters.putString("message", txtPostToWall.getText().toString()); 
//   parameters.putString("description", getString(R.string.app_desc)); 

      response = Utility.mFacebook.request("me/feed", parameters, "POST"); 
      txtPostToWall.setText(""); 
      this.finish(); 

      Log.d("Tests", "got response: " + response); 

      if (response == null || response.equals("") || response.equals("false")) { 
       Log.v("Error", "Blank response"); 
      } 
     } 
     catch(Exception e) { 
      e.printStackTrace(); 
     } 
    } 

Die DDMS Warnungen: (. Sehr, sehr lange)

03-30 20:02:53.290: W/Bundle(17941): Key message expected byte[] but value was a java.lang.String. The default value <null> was returned. 
    03-30 20:02:53.306: W/Bundle(17941): Attempt to cast generated internal exception: 
    03-30 20:02:53.306: W/Bundle(17941): java.lang.ClassCastException: java.lang.String 
    03-30 20:02:53.306: W/Bundle(17941): at android.os.Bundle.getByteArray(Bundle.java:1305) 
    03-30 20:02:53.306: W/Bundle(17941): at com.facebook.android.Util.openUrl(Util.java:161) 
    03-30 20:02:53.306: W/Bundle(17941): at com.facebook.android.Facebook.request(Facebook.java:751) 
    03-30 20:02:53.306: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate.postToWall(StatusUpdate.java:68) 
    03-30 20:02:53.306: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate$2.onClick(StatusUpdate.java:48) 
    03-30 20:02:53.306: W/Bundle(17941): at android.view.View.performClick(View.java:2538) 
    03-30 20:02:53.306: W/Bundle(17941): at android.view.View$PerformClick.run(View.java:9152) 
    03-30 20:02:53.306: W/Bundle(17941): at android.os.Handler.handleCallback(Handler.java:587) 
    03-30 20:02:53.306: W/Bundle(17941): at android.os.Handler.dispatchMessage(Handler.java:92) 
    03-30 20:02:53.306: W/Bundle(17941): at android.os.Looper.loop(Looper.java:130) 
    03-30 20:02:53.306: W/Bundle(17941): at android.app.ActivityThread.main(ActivityThread.java:3687) 
    03-30 20:02:53.306: W/Bundle(17941): at java.lang.reflect.Method.invokeNative(Native Method) 
    03-30 20:02:53.306: W/Bundle(17941): at java.lang.reflect.Method.invoke(Method.java:507) 
    03-30 20:02:53.306: W/Bundle(17941): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
    03-30 20:02:53.306: W/Bundle(17941): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
    03-30 20:02:53.306: W/Bundle(17941): at dalvik.system.NativeStart.main(Native Method) 
    03-30 20:02:53.310: W/Bundle(17941): Key access_token expected byte[] but value was a java.lang.String. The default value <null> was returned. 
    03-30 20:02:53.325: W/Bundle(17941): Attempt to cast generated internal exception: 
    03-30 20:02:53.325: W/Bundle(17941): java.lang.ClassCastException: java.lang.String 
    03-30 20:02:53.325: W/Bundle(17941): at android.os.Bundle.getByteArray(Bundle.java:1305) 
    03-30 20:02:53.325: W/Bundle(17941): at com.facebook.android.Util.openUrl(Util.java:161) 
    03-30 20:02:53.325: W/Bundle(17941): at com.facebook.android.Facebook.request(Facebook.java:751) 
    03-30 20:02:53.325: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate.postToWall(StatusUpdate.java:68) 
    03-30 20:02:53.325: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate$2.onClick(StatusUpdate.java:48) 
    03-30 20:02:53.325: W/Bundle(17941): at android.view.View.performClick(View.java:2538) 
    03-30 20:02:53.325: W/Bundle(17941): at android.view.View$PerformClick.run(View.java:9152) 
    03-30 20:02:53.325: W/Bundle(17941): at android.os.Handler.handleCallback(Handler.java:587) 
    03-30 20:02:53.325: W/Bundle(17941): at android.os.Handler.dispatchMessage(Handler.java:92) 
    03-30 20:02:53.325: W/Bundle(17941): at android.os.Looper.loop(Looper.java:130) 
    03-30 20:02:53.325: W/Bundle(17941): at android.app.ActivityThread.main(ActivityThread.java:3687) 
    03-30 20:02:53.325: W/Bundle(17941): at java.lang.reflect.Method.invokeNative(Native Method) 
    03-30 20:02:53.325: W/Bundle(17941): at java.lang.reflect.Method.invoke(Method.java:507) 
    03-30 20:02:53.325: W/Bundle(17941): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
    03-30 20:02:53.325: W/Bundle(17941): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
    03-30 20:02:53.325: W/Bundle(17941): at dalvik.system.NativeStart.main(Native Method) 
    03-30 20:02:53.325: W/Bundle(17941): Key format expected byte[] but value was a java.lang.String. The default value <null> was returned. 
    03-30 20:02:53.341: W/Bundle(17941): Attempt to cast generated internal exception: 
    03-30 20:02:53.341: W/Bundle(17941): java.lang.ClassCastException: java.lang.String 
    03-30 20:02:53.341: W/Bundle(17941): at android.os.Bundle.getByteArray(Bundle.java:1305) 
    03-30 20:02:53.341: W/Bundle(17941): at com.facebook.android.Util.openUrl(Util.java:161) 
    03-30 20:02:53.341: W/Bundle(17941): at com.facebook.android.Facebook.request(Facebook.java:751) 
    03-30 20:02:53.341: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate.postToWall(StatusUpdate.java:68) 
    03-30 20:02:53.341: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate$2.onClick(StatusUpdate.java:48) 
    03-30 20:02:53.341: W/Bundle(17941): at android.view.View.performClick(View.java:2538) 
    03-30 20:02:53.341: W/Bundle(17941): at android.view.View$PerformClick.run(View.java:9152) 
    03-30 20:02:53.341: W/Bundle(17941): at android.os.Handler.handleCallback(Handler.java:587) 
    03-30 20:02:53.341: W/Bundle(17941): at android.os.Handler.dispatchMessage(Handler.java:92) 
    03-30 20:02:53.341: W/Bundle(17941): at android.os.Looper.loop(Looper.java:130) 
    03-30 20:02:53.341: W/Bundle(17941): at android.app.ActivityThread.main(ActivityThread.java:3687) 
    03-30 20:02:53.341: W/Bundle(17941): at java.lang.reflect.Method.invokeNative(Native Method) 
    03-30 20:02:53.341: W/Bundle(17941): at java.lang.reflect.Method.invoke(Method.java:507) 
    03-30 20:02:53.341: W/Bundle(17941): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
    03-30 20:02:53.341: W/Bundle(17941): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
    03-30 20:02:53.341: W/Bundle(17941): at dalvik.system.NativeStart.main(Native Method) 
    03-30 20:02:53.353: W/Bundle(17941): Key message expected byte[] but value was a java.lang.String. The default value <null> was returned. 
    03-30 20:02:53.368: W/Bundle(17941): Attempt to cast generated internal exception: 
    03-30 20:02:53.368: W/Bundle(17941): java.lang.ClassCastException: java.lang.String 
    03-30 20:02:53.368: W/Bundle(17941): at android.os.Bundle.getByteArray(Bundle.java:1305) 
    03-30 20:02:53.368: W/Bundle(17941): at com.facebook.android.Util.encodePostBody(Util.java:69) 
    03-30 20:02:53.368: W/Bundle(17941): at com.facebook.android.Util.openUrl(Util.java:188) 
    03-30 20:02:53.368: W/Bundle(17941): at com.facebook.android.Facebook.request(Facebook.java:751) 
    03-30 20:02:53.368: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate.postToWall(StatusUpdate.java:68) 
    03-30 20:02:53.368: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate$2.onClick(StatusUpdate.java:48) 
    03-30 20:02:53.368: W/Bundle(17941): at android.view.View.performClick(View.java:2538) 
    03-30 20:02:53.368: W/Bundle(17941): at android.view.View$PerformClick.run(View.java:9152) 
    03-30 20:02:53.368: W/Bundle(17941): at android.os.Handler.handleCallback(Handler.java:587) 
    03-30 20:02:53.368: W/Bundle(17941): at android.os.Handler.dispatchMessage(Handler.java:92) 
    03-30 20:02:53.368: W/Bundle(17941): at android.os.Looper.loop(Looper.java:130) 
    03-30 20:02:53.368: W/Bundle(17941): at android.app.ActivityThread.main(ActivityThread.java:3687) 
    03-30 20:02:53.368: W/Bundle(17941): at java.lang.reflect.Method.invokeNative(Native Method) 
    03-30 20:02:53.368: W/Bundle(17941): at java.lang.reflect.Method.invoke(Method.java:507) 
    03-30 20:02:53.368: W/Bundle(17941): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
    03-30 20:02:53.368: W/Bundle(17941): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
    03-30 20:02:53.368: W/Bundle(17941): at dalvik.system.NativeStart.main(Native Method) 
    03-30 20:02:53.368: W/Bundle(17941): Key method expected byte[] but value was a java.lang.String. The default value <null> was returned. 
    03-30 20:02:53.384: W/Bundle(17941): Attempt to cast generated internal exception: 
    03-30 20:02:53.384: W/Bundle(17941): java.lang.ClassCastException: java.lang.String 
    03-30 20:02:53.384: W/Bundle(17941): at android.os.Bundle.getByteArray(Bundle.java:1305) 
    03-30 20:02:53.384: W/Bundle(17941): at com.facebook.android.Util.encodePostBody(Util.java:69) 
    03-30 20:02:53.384: W/Bundle(17941): at com.facebook.android.Util.openUrl(Util.java:188) 
    03-30 20:02:53.384: W/Bundle(17941): at com.facebook.android.Facebook.request(Facebook.java:751) 
    03-30 20:02:53.384: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate.postToWall(StatusUpdate.java:68) 
    03-30 20:02:53.384: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate$2.onClick(StatusUpdate.java:48) 
    03-30 20:02:53.384: W/Bundle(17941): at android.view.View.performClick(View.java:2538) 
    03-30 20:02:53.384: W/Bundle(17941): at android.view.View$PerformClick.run(View.java:9152) 
    03-30 20:02:53.384: W/Bundle(17941): at android.os.Handler.handleCallback(Handler.java:587) 
    03-30 20:02:53.384: W/Bundle(17941): at android.os.Handler.dispatchMessage(Handler.java:92) 
    03-30 20:02:53.384: W/Bundle(17941): at android.os.Looper.loop(Looper.java:130) 
    03-30 20:02:53.384: W/Bundle(17941): at android.app.ActivityThread.main(ActivityThread.java:3687) 
    03-30 20:02:53.384: W/Bundle(17941): at java.lang.reflect.Method.invokeNative(Native Method) 
    03-30 20:02:53.384: W/Bundle(17941): at java.lang.reflect.Method.invoke(Method.java:507) 
    03-30 20:02:53.384: W/Bundle(17941): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
    03-30 20:02:53.384: W/Bundle(17941): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
    03-30 20:02:53.384: W/Bundle(17941): at dalvik.system.NativeStart.main(Native Method) 
    03-30 20:02:53.388: W/Bundle(17941): Key access_token expected byte[] but value was a java.lang.String. The default value <null> was returned. 
    03-30 20:02:53.403: W/Bundle(17941): Attempt to cast generated internal exception: 
    03-30 20:02:53.403: W/Bundle(17941): java.lang.ClassCastException: java.lang.String 
    03-30 20:02:53.403: W/Bundle(17941): at android.os.Bundle.getByteArray(Bundle.java:1305) 
    03-30 20:02:53.403: W/Bundle(17941): at com.facebook.android.Util.encodePostBody(Util.java:69) 
    03-30 20:02:53.403: W/Bundle(17941): at com.facebook.android.Util.openUrl(Util.java:188) 
    03-30 20:02:53.403: W/Bundle(17941): at com.facebook.android.Facebook.request(Facebook.java:751) 
    03-30 20:02:53.403: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate.postToWall(StatusUpdate.java:68) 
    03-30 20:02:53.403: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate$2.onClick(StatusUpdate.java:48) 
    03-30 20:02:53.403: W/Bundle(17941): at android.view.View.performClick(View.java:2538) 
    03-30 20:02:53.403: W/Bundle(17941): at android.view.View$PerformClick.run(View.java:9152) 
    03-30 20:02:53.403: W/Bundle(17941): at android.os.Handler.handleCallback(Handler.java:587) 
    03-30 20:02:53.403: W/Bundle(17941): at android.os.Handler.dispatchMessage(Handler.java:92) 
    03-30 20:02:53.403: W/Bundle(17941): at android.os.Looper.loop(Looper.java:130) 
    03-30 20:02:53.403: W/Bundle(17941): at android.app.ActivityThread.main(ActivityThread.java:3687) 
    03-30 20:02:53.403: W/Bundle(17941): at java.lang.reflect.Method.invokeNative(Native Method) 
    03-30 20:02:53.403: W/Bundle(17941): at java.lang.reflect.Method.invoke(Method.java:507) 
    03-30 20:02:53.403: W/Bundle(17941): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
    03-30 20:02:53.403: W/Bundle(17941): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
    03-30 20:02:53.403: W/Bundle(17941): at dalvik.system.NativeStart.main(Native Method) 
    03-30 20:02:53.403: W/Bundle(17941): Key format expected byte[] but value was a java.lang.String. The default value <null> was returned. 
    03-30 20:02:53.423: W/Bundle(17941): Attempt to cast generated internal exception: 
    03-30 20:02:53.423: W/Bundle(17941): java.lang.ClassCastException: java.lang.String 
    03-30 20:02:53.423: W/Bundle(17941): at android.os.Bundle.getByteArray(Bundle.java:1305) 
    03-30 20:02:53.423: W/Bundle(17941): at com.facebook.android.Util.encodePostBody(Util.java:69) 
    03-30 20:02:53.423: W/Bundle(17941): at com.facebook.android.Util.openUrl(Util.java:188) 
    03-30 20:02:53.423: W/Bundle(17941): at com.facebook.android.Facebook.request(Facebook.java:751) 
    03-30 20:02:53.423: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate.postToWall(StatusUpdate.java:68) 
    03-30 20:02:53.423: W/Bundle(17941): at com.dzinesunlimited.sociallyyou.StatusUpdate$2.onClick(StatusUpdate.java:48) 
    03-30 20:02:53.423: W/Bundle(17941): at android.view.View.performClick(View.java:2538) 
    03-30 20:02:53.423: W/Bundle(17941): at android.view.View$PerformClick.run(View.java:9152) 
    03-30 20:02:53.423: W/Bundle(17941): at android.os.Handler.handleCallback(Handler.java:587) 
    03-30 20:02:53.423: W/Bundle(17941): at android.os.Handler.dispatchMessage(Handler.java:92) 
    03-30 20:02:53.423: W/Bundle(17941): at android.os.Looper.loop(Looper.java:130) 
    03-30 20:02:53.423: W/Bundle(17941): at android.app.ActivityThread.main(ActivityThread.java:3687) 
    03-30 20:02:53.423: W/Bundle(17941): at java.lang.reflect.Method.invokeNative(Native Method) 
    03-30 20:02:53.423: W/Bundle(17941): at java.lang.reflect.Method.invoke(Method.java:507) 
    03-30 20:02:53.423: W/Bundle(17941): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
    03-30 20:02:53.423: W/Bundle(17941): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
    03-30 20:02:53.423: W/Bundle(17941): at dalvik.system.NativeStart.main(Native Method) 

Jede Hilfe ist wirklich zu schätzen.

Antwort

2

Nun gut und gut. Ich fühle mich wie ein totaler Trottel für die wichtigen Warnungen ignoriert zu haben ..... :-(

Der Trick an der Linie 69 von der Util.java in dem Facebook-SDK zu ändern war:

if (parameters.getByteArray(key) != null) { 

zu :

if (parameters.get(key) instanceof byte[]) { 

Dank der Lösung hier gepostet: https://stackoverflow.com/a/3927541/450534

Verwandte Themen