2011-11-17 70 views
1

应用程序崩溃的时候,我想分享的Android的Facebook-SDK崩溃

这是代码

private void share() { 
    facebookClient = new Facebook(APP_API_ID); 
    facebookClient.authorize(this, 
      new String[] {"publish_stream", "read_stream", "offline_access"}, this); 
} 

@Override 
public void onComplete(Bundle values) { 

    if (!values.containsKey("post_id")) 
    { 

    try { 
      String response = facebookClient.request("me"); 
      Bundle parameters = new Bundle(); 
      parameters.putString("name","Name"); 
      parameters.putString("description", "Description"); 
      parameters.putString("link", "Link"); 
      parameters.putString("picture","Picture"); 
      response = facebookClient.request("me/feed", parameters, "POST"); 
      Log.d("Tests", "got response: " + response); 
      if (response == null || response.equals("") || response.equals("false")) { 
       Log.v("Error", "Blank response"); 
      } 

    } catch(Exception e) { 
     e.printStackTrace(); 
    } 
    } 
} 

这是崩溃日志

11-17 18:22:49.590: ERROR/AndroidRuntime(3237): java.lang.NullPointerException 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.webkit.WebView.onWindowFocusChanged(WebView.java:4198) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.view.View.dispatchWindowFocusChanged(View.java:3788) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:658) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1921) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.os.Handler.dispatchMessage(Handler.java:99) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.os.Looper.loop(Looper.java:123) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at android.app.ActivityThread.main(ActivityThread.java:4627) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at java.lang.reflect.Method.invokeNative(Native Method) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at java.lang.reflect.Method.invoke(Method.java:521) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
11-17 18:22:49.590: ERROR/AndroidRuntime(3237):  at dalvik.system.NativeStart.main(Native Method) 

是否有解决方案

感谢

+0

邮政完整的堆栈跟踪更换

String response = facebookClient.request("me"); 

。另外 - NullPointerExceptions是最容易找到的。所有你需要做的就是调试,并且步入NPE发生的地步,然后评估你的变量。 – Jack

+0

请参阅http://stackoverflow.com/questions/6525005/npe-at-android-webkit-webview-onwindowfocuschanged – larham1

回答

0

试试与

String response = ""; 
+0

它没有帮助我 – user998955

+0

你知道哪一行返回nullpointerException吗?你可以在每行调试和中断,直到应用程序崩溃。 –

+0

此代码适用于Galaxy,但不适用于G1 – user998955