Android中的Facebook更新失败

时间:2012-03-25 21:46:24

标签: android facebook

HY!

我使用easyfacebookandroidsdk(http://www.easyfacebookandroidsdk.com/guide.asp)在Facebook上发布状态。

我制作了一个FB应用程序并输入了我的Android Key Hash。

我的代码:

public class FBConnect extends GDActivity implements LoginListener{

     private FBLoginManager fbManager;

     //replace it with your own Facebook App ID
     String title = "Herr der Ringe";

     @Override
     public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //setContentView(R.layout.main);
      setTitle("Facebook");
      //Bundle extras = getIntent().getExtras();
      //title=extras.getString("title");
    shareFacebook();
     }
     public void shareFacebook() {

            //change the permissions according to the function you want to use 
                    String permissions[] = { "read_stream","publish_actions" };

                    //change the parameters with those of your application
                    fbManager = new FBLoginManager(this, R.layout.main,
                                    "xxxxxxxxx", permissions);

                    if (fbManager.existsSavedFacebook()) {
                            fbManager.loadFacebook();
                    } else {

                            fbManager.login();
                    }
            }

            @Override
            protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                    fbManager.loginSuccess(data);
            }

            public void loginFail() {
                    fbManager.displayToast("Login failed!");

            }

            public void logoutSuccess() {
                    fbManager.displayToast("Logout success!");
            }

            public void loginSuccess(Facebook facebook) {

                    //library use example
                    RestApi rest = new RestApi(facebook);
                    try {

                        rest.setStatus("I just watched "+title+"  and marked it in TVBrain for Android");
                        Log.e("XXX FB","OK");
                    } catch (EasyFacebookError e1) {
                        // TODO Auto-generated catch block
                        Log.e("XXX FB","ERROR");
                        e1.printStackTrace();
                    }



            }



}

错误:

03-25 23:36:42.358: W/Bundle(931): Key status expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-25 23:36:42.365: W/Bundle(931): Attempt to cast generated internal exception:
03-25 23:36:42.365: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[]
03-25 23:36:42.365: W/Bundle(931):  at android.os.Bundle.getByteArray(Bundle.java:1363)
03-25 23:36:42.365: W/Bundle(931):  at com.easy.facebook.android.util.Util.openUrl(Util.java:157)
03-25 23:36:42.365: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119)
03-25 23:36:42.365: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100)
03-25 23:36:42.365: W/Bundle(931):  at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72)
03-25 23:36:42.365: W/Bundle(931):  at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33)
03-25 23:36:42.365: W/Bundle(931):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 23:36:42.365: W/Bundle(931):  at android.os.Looper.loop(Looper.java:137)
03-25 23:36:42.365: W/Bundle(931):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-25 23:36:42.365: W/Bundle(931):  at java.lang.reflect.Method.invokeNative(Native Method)
03-25 23:36:42.365: W/Bundle(931):  at java.lang.reflect.Method.invoke(Method.java:511)
03-25 23:36:42.365: W/Bundle(931):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-25 23:36:42.365: W/Bundle(931):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-25 23:36:42.365: W/Bundle(931):  at dalvik.system.NativeStart.main(Native Method)
03-25 23:36:42.365: W/Bundle(931): Key access_token expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-25 23:36:42.369: W/Bundle(931): Attempt to cast generated internal exception:
03-25 23:36:42.369: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[]
03-25 23:36:42.369: W/Bundle(931):  at android.os.Bundle.getByteArray(Bundle.java:1363)
03-25 23:36:42.369: W/Bundle(931):  at com.easy.facebook.android.util.Util.openUrl(Util.java:157)
03-25 23:36:42.369: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119)
03-25 23:36:42.369: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100)
03-25 23:36:42.369: W/Bundle(931):  at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72)
03-25 23:36:42.369: W/Bundle(931):  at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33)
03-25 23:36:42.369: W/Bundle(931):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 23:36:42.369: W/Bundle(931):  at android.os.Looper.loop(Looper.java:137)
03-25 23:36:42.369: W/Bundle(931):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-25 23:36:42.369: W/Bundle(931):  at java.lang.reflect.Method.invokeNative(Native Method)
03-25 23:36:42.369: W/Bundle(931):  at java.lang.reflect.Method.invoke(Method.java:511)
03-25 23:36:42.369: W/Bundle(931):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-25 23:36:42.369: W/Bundle(931):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-25 23:36:42.369: W/Bundle(931):  at dalvik.system.NativeStart.main(Native Method)
03-25 23:36:42.369: W/Bundle(931): Key method expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-25 23:36:42.373: W/Bundle(931): Attempt to cast generated internal exception:
03-25 23:36:42.373: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[]
03-25 23:36:42.373: W/Bundle(931):  at android.os.Bundle.getByteArray(Bundle.java:1363)
03-25 23:36:42.373: W/Bundle(931):  at com.easy.facebook.android.util.Util.openUrl(Util.java:157)
03-25 23:36:42.373: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119)
03-25 23:36:42.373: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100)
03-25 23:36:42.373: W/Bundle(931):  at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72)
03-25 23:36:42.373: W/Bundle(931):  at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33)
03-25 23:36:42.373: W/Bundle(931):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 23:36:42.373: W/Bundle(931):  at android.os.Looper.loop(Looper.java:137)
03-25 23:36:42.373: W/Bundle(931):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-25 23:36:42.373: W/Bundle(931):  at java.lang.reflect.Method.invokeNative(Native Method)
03-25 23:36:42.373: W/Bundle(931):  at java.lang.reflect.Method.invoke(Method.java:511)
03-25 23:36:42.373: W/Bundle(931):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-25 23:36:42.373: W/Bundle(931):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-25 23:36:42.373: W/Bundle(931):  at dalvik.system.NativeStart.main(Native Method)
03-25 23:36:42.377: W/Bundle(931): Key format expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-25 23:36:42.381: W/Bundle(931): Attempt to cast generated internal exception:
03-25 23:36:42.381: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[]
03-25 23:36:42.381: W/Bundle(931):  at android.os.Bundle.getByteArray(Bundle.java:1363)
03-25 23:36:42.381: W/Bundle(931):  at com.easy.facebook.android.util.Util.openUrl(Util.java:157)
03-25 23:36:42.381: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119)
03-25 23:36:42.381: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100)
03-25 23:36:42.381: W/Bundle(931):  at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72)
03-25 23:36:42.381: W/Bundle(931):  at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33)
03-25 23:36:42.381: W/Bundle(931):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 23:36:42.381: W/Bundle(931):  at android.os.Looper.loop(Looper.java:137)
03-25 23:36:42.381: W/Bundle(931):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-25 23:36:42.381: W/Bundle(931):  at java.lang.reflect.Method.invokeNative(Native Method)
03-25 23:36:42.381: W/Bundle(931):  at java.lang.reflect.Method.invoke(Method.java:511)
03-25 23:36:42.381: W/Bundle(931):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-25 23:36:42.381: W/Bundle(931):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-25 23:36:42.381: W/Bundle(931):  at dalvik.system.NativeStart.main(Native Method)
03-25 23:36:43.740: W/Bundle(931): Key status expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-25 23:36:43.744: W/Bundle(931): Attempt to cast generated internal exception:
03-25 23:36:43.744: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[]
03-25 23:36:43.744: W/Bundle(931):  at android.os.Bundle.getByteArray(Bundle.java:1363)
03-25 23:36:43.744: W/Bundle(931):  at com.easy.facebook.android.util.Util.encodePostBody(Util.java:65)
03-25 23:36:43.744: W/Bundle(931):  at com.easy.facebook.android.util.Util.openUrl(Util.java:184)
03-25 23:36:43.744: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119)
03-25 23:36:43.744: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100)
03-25 23:36:43.744: W/Bundle(931):  at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72)
03-25 23:36:43.744: W/Bundle(931):  at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33)
03-25 23:36:43.744: W/Bundle(931):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 23:36:43.744: W/Bundle(931):  at android.os.Looper.loop(Looper.java:137)
03-25 23:36:43.744: W/Bundle(931):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-25 23:36:43.744: W/Bundle(931):  at java.lang.reflect.Method.invokeNative(Native Method)
03-25 23:36:43.744: W/Bundle(931):  at java.lang.reflect.Method.invoke(Method.java:511)
03-25 23:36:43.744: W/Bundle(931):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-25 23:36:43.744: W/Bundle(931):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-25 23:36:43.744: W/Bundle(931):  at dalvik.system.NativeStart.main(Native Method)
03-25 23:36:43.744: W/Bundle(931): Key access_token expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-25 23:36:43.748: W/Bundle(931): Attempt to cast generated internal exception:
03-25 23:36:43.748: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[]
03-25 23:36:43.748: W/Bundle(931):  at android.os.Bundle.getByteArray(Bundle.java:1363)
03-25 23:36:43.748: W/Bundle(931):  at com.easy.facebook.android.util.Util.encodePostBody(Util.java:65)
03-25 23:36:43.748: W/Bundle(931):  at com.easy.facebook.android.util.Util.openUrl(Util.java:184)
03-25 23:36:43.748: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119)
03-25 23:36:43.748: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100)
03-25 23:36:43.748: W/Bundle(931):  at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72)
03-25 23:36:43.748: W/Bundle(931):  at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33)
03-25 23:36:43.748: W/Bundle(931):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 23:36:43.748: W/Bundle(931):  at android.os.Looper.loop(Looper.java:137)
03-25 23:36:43.748: W/Bundle(931):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-25 23:36:43.748: W/Bundle(931):  at java.lang.reflect.Method.invokeNative(Native Method)
03-25 23:36:43.748: W/Bundle(931):  at java.lang.reflect.Method.invoke(Method.java:511)
03-25 23:36:43.748: W/Bundle(931):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-25 23:36:43.748: W/Bundle(931):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-25 23:36:43.748: W/Bundle(931):  at dalvik.system.NativeStart.main(Native Method)
03-25 23:36:43.748: W/Bundle(931): Key method expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-25 23:36:43.752: W/Bundle(931): Attempt to cast generated internal exception:
03-25 23:36:43.752: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[]
03-25 23:36:43.752: W/Bundle(931):  at android.os.Bundle.getByteArray(Bundle.java:1363)
03-25 23:36:43.752: W/Bundle(931):  at com.easy.facebook.android.util.Util.encodePostBody(Util.java:65)
03-25 23:36:43.752: W/Bundle(931):  at com.easy.facebook.android.util.Util.openUrl(Util.java:184)
03-25 23:36:43.752: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119)
03-25 23:36:43.752: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100)
03-25 23:36:43.752: W/Bundle(931):  at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72)
03-25 23:36:43.752: W/Bundle(931):  at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33)
03-25 23:36:43.752: W/Bundle(931):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 23:36:43.752: W/Bundle(931):  at android.os.Looper.loop(Looper.java:137)
03-25 23:36:43.752: W/Bundle(931):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-25 23:36:43.752: W/Bundle(931):  at java.lang.reflect.Method.invokeNative(Native Method)
03-25 23:36:43.752: W/Bundle(931):  at java.lang.reflect.Method.invoke(Method.java:511)
03-25 23:36:43.752: W/Bundle(931):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-25 23:36:43.752: W/Bundle(931):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-25 23:36:43.752: W/Bundle(931):  at dalvik.system.NativeStart.main(Native Method)
03-25 23:36:43.752: W/Bundle(931): Key format expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-25 23:36:43.756: W/Bundle(931): Attempt to cast generated internal exception:
03-25 23:36:43.756: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[]
03-25 23:36:43.756: W/Bundle(931):  at android.os.Bundle.getByteArray(Bundle.java:1363)
03-25 23:36:43.756: W/Bundle(931):  at com.easy.facebook.android.util.Util.encodePostBody(Util.java:65)
03-25 23:36:43.756: W/Bundle(931):  at com.easy.facebook.android.util.Util.openUrl(Util.java:184)
03-25 23:36:43.756: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119)
03-25 23:36:43.756: W/Bundle(931):  at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100)
03-25 23:36:43.756: W/Bundle(931):  at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72)
03-25 23:36:43.756: W/Bundle(931):  at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33)
03-25 23:36:43.756: W/Bundle(931):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 23:36:43.756: W/Bundle(931):  at android.os.Looper.loop(Looper.java:137)
03-25 23:36:43.756: W/Bundle(931):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-25 23:36:43.756: W/Bundle(931):  at java.lang.reflect.Method.invokeNative(Native Method)
03-25 23:36:43.756: W/Bundle(931):  at java.lang.reflect.Method.invoke(Method.java:511)
03-25 23:36:43.756: W/Bundle(931):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-25 23:36:43.756: W/Bundle(931):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-25 23:36:43.756: W/Bundle(931):  at dalvik.system.NativeStart.main(Native Method)

Facebook中没有更新。 请帮忙。

1 个答案:

答案 0 :(得分:1)

呃,堆栈跟踪说你正在尝试将一个String转换为byte [],这听起来应该可以工作但不会。

很难说它在哪里发生,因为你使用的是我不熟悉的Facebook API。

按照堆栈跟踪,直到找到代码中的呼叫。然后从那里开始。

我会说它是在 Facebook API中的Util.openUrl()。这是否期望一个byte [],并且你传递一个字符串?