ここのサイトのプログラムを実行したところLog部分に記述されているresponseに何も値を与えてないせいか、java.lang.NullPointerExceptionがおきてJSONをLogに表示できません。どのように解決したらよいか教えてください
errorログ
05-16 21:50:50.399 21766-21791/? E/DataScheduler: isDataSchedulerEnabled():false 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: FATAL EXCEPTION: main 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: Process: info.elecafe.checkinfood, PID: 21766 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: java.lang.NullPointerException 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at info.elecafe.checkinfood.MainActivity$1.onCompleted(MainActivity.java:59) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at com.facebook.GraphRequest$5.run(GraphRequest.java:1379) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:733) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at android.os.Looper.loop(Looper.java:136) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5105) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608) 05-16 21:50:51.819 21766-21766/info.elecafe.checkinfood E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
59行目はLog.iの行になります。
Java
1private void GraphApiTest() { 2 new GraphRequest( 3 AccessToken.getCurrentAccessToken(), 4 "/me/feed", 5 null, 6 HttpMethod.GET, 7 new GraphRequest.Callback() { 8 public void onCompleted(GraphResponse response) { 9 Log.i(TAG, response.getJSONObject().toString()); 10 } 11 } 12 ).executeAsync(); 13}
回答1件
あなたの回答
tips
プレビュー