应用程序崩溃
这是代码
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 :(得分:0)
尝试替换
String response = facebookClient.request("me");
带
String response = "";