0
JSONObject json = null;
                            try {
                                json = Util.parseJson(fb.request("me"));
                            } catch (MalformedURLException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            } catch (FacebookError e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }     

onComplete()上記はメソッド 内のコードです 。

" https://graph.facebook.com/me?access_token= * *** * ブラウザで入力すると完璧です json 応答を受け取りますが、facebook sdk Util.class crashes 以下は logcat エラーです。

FATAL EXCEPTION: main
java.lang.NullPointerException
at libcore.net.http.HttpEngine.writeRequestHeaders(HttpEngine.java:625)
at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:771)
at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:270)
at com.facebook.android.Util.openUrl(Util.java:211)
at com.facebook.android.Facebook.requestImpl(Facebook.java:790)
    at com.facebook.android.Facebook.request(Facebook.java:717)
    at com.example.check5.MainActivity$1$1.onComplete(MainActivity.java:112)
    at com.facebook.android.Facebook.onSessionCallback(Facebook.java:331)
    at com.facebook.android.Facebook.access$11(Facebook.java:312)
    at com.facebook.android.Facebook$1.call(Facebook.java:291)
    at com.facebook.Session$3$1.run(Session.java:1316)
    at android.os.Handler.handleCallback(Handler.java:605)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:4945)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)     

何が問題なのか教えてください。事前に感謝します。

4

2 に答える 2

0

コードにnullポイント例外を追加してみてください

try {
                            json = Util.parseJson(fb.request("me"));
                        } catch (NullPointException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
于 2012-11-26T12:15:18.907 に答える
0
 Bundle b = new Bundle();
    b.putString("access_token", facebookManager.mFacebook.getAccessToken());
    b.putString("query", "SELECT name FROM user WHERE uid = me()");

    try {
        String myResult = Util.openUrl("https://api.facebook.com/method/fql.query", "GET", b);
            Log.i("MyResult", myResult);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
于 2012-11-26T11:24:19.057 に答える