addressalign-toparrow-leftarrow-leftarrow-right-10x10arrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1languagelaunch-new-window--smalllight-bulblightning-boltlinklocation-pinlockm-swarmSearchmailmediummessagesminusmobilemoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstar-shapestartickettrashtriangle-downtriangle-uptwitteruserwarningyahooyoutube

Re: [blrdroid] [codehelp]null pointer exception on facebook getactivity result

From: Sutirth C.
Sent on: Wednesday, August 12, 2015, 5:15 PM
Hi Giridhar,

I would suggest not to use Profile class from facebook has similar issue. Instead use the response from GraphResponse and get required data for e.g in your case response.getJSONObject.getString("email");

hope this helps.

Cheers,
Sutirth

On Wed, Aug 12, 2015 at 5:07 PM, GIRIDHAR BM <[address removed]> wrote:
 

      {
        "_id": {
            "$oid": "55c9c9979bc[masked]c89b2f"
        },
        "stackTrace": {
            "app_start_date": "[masked]T15:37:32.000+05:30",
            "stackTrace": "java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=-1, data=Intent { (has extras) }} to activity {com.splitrides/com.splitrides.MainActivity}: java.lang.NullPointerException\n\tat android.app.ActivityThread.deliverResults(ActivityThread.java:3389)\n\tat android.app.ActivityThread.handleSendResult(ActivityThread.java:3432)\n\tat android.app.ActivityThread.access$1300(ActivityThread.java:144)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1253)\n\tat android.os.Handler.dispatchMessage(Handler.java:102)\n\tat android.os.Looper.loop(Looper.java:136)\n\tat android.app.ActivityThread.main(ActivityThread.java:5146)\n\tat java.lang.reflect.Method.invokeNative(Native Method)\n\tat java.lang.reflect.Method.invoke(Method.java:515)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)\n\tat dalvik.system.NativeStart.main(Native Method)\nCaused by: java.lang.NullPointerException\n\tat com.splitrides.MainActivity$1.onSuccess(MainActivity.java:369)\n\tat com.splitrides.MainActivity$1.onSuccess(MainActivity.java:364)\n\tat com.facebook.login.LoginManager.finishLogin(LoginManager.java:508)\n\tat com.facebook.login.LoginManager.onActivityResult(LoginManager.java:192)\n\tat com.facebook.login.LoginManager$1.onActivityResult(LoginManager.java:140)\n\tat com.facebook.internal.CallbackManagerImpl.onActivityResult(CallbackManagerImpl.java:82)\n\tat com.splitrides.MainActivity.onActivityResult(MainActivity.java:788)\n\tat android.app.Activity.dispatchActivityResult(Activity.java:5423)\n\tat android.app.ActivityThread.deliverResults(ActivityThread.java:3385)\n\t... 11 more\njava.lang.NullPointerException\n\tat com.splitrides.MainActivity$1.onSuccess(MainActivity.java:369)\n\tat com.splitrides.MainActivity$1.onSuccess(MainActivity.java:364)\n\tat com.facebook.login.LoginManager.finishLogin(LoginManager.java:508)\n\tat com.facebook.login.LoginManager.onActivityResult(LoginManager.java:192)\n\tat com.facebook.login.LoginManager$1.onActivityResult(LoginManager.java:140)\n\tat com.facebook.internal.CallbackManagerImpl.onActivityResult(CallbackManagerImpl.java:82)\n\tat com.splitrides.MainActivity.onActivityResult(MainActivity.java:788)\n\tat android.app.Activity.dispatchActivityResult(Activity.java:5423)\n\tat android.app.ActivityThread.deliverResults(ActivityThread.java:3385)\n\tat android.app.ActivityThread.handleSendResult(ActivityThread.java:3432)\n\tat android.app.ActivityThread.access$1300(ActivityThread.java:144)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1253)\n\tat android.os.Handler.dispatchMessage(Handler.java:102)\n\tat android.os.Looper.loop(Looper.java:136)\n\tat android.app.ActivityThread.main(ActivityThread.java:5146)\n\tat java.lang.reflect.Method.invokeNative(Native Method)\n\tat java.lang.reflect.Method.invoke(Method.java:515)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)\n\tat dalvik.system.NativeStart.main(Native Method)\n",
            "time": "15:38:23",
            "day": "[masked]"
        },
        "__v": 0 }

Hi all,
  I am getting this error above after login to facebook from my app and facebook asks for permisssion 2 times(dont know if this is part of the exception).After that the app crashes. How to resolve this issue?

Here is the code below i have written

    @Override
    public void onFacebookLoginButtonClicked()
    {
        AccessToken token = AccessToken.getCurrentAccessToken();
        onregister();
        if (token == null) {
            LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "user_friends", "email", "user_birthday"));
        }
        else{
            LoginManager.getInstance().logOut();
        }
    }

      @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        SharedPreferenceManager.setApplicationContext(getApplicationContext());
        onregister();
        SharedPreferenceManager.setPreference("notificationcount", 0);
    FacebookSdk.sdkInitialize(this.getApplicationContext());
        LoginButton authButton = (LoginButton)findViewById(R.id.facebook_button);
        callbackManager = CallbackManager.Factory.create();


        LoginManager.getInstance().registerCallback(callbackManager,
                new FacebookCallback<LoginResult>() {
                    @Override
                    public void onSuccess(final LoginResult loginResult) {

                        final Profile profile = Profile.getCurrentProfile();
                        SharedPreferenceManager.setPreference("id", profile.getId());
                        GraphRequest request = GraphRequest.newMeRequest(
                                AccessToken.getCurrentAccessToken(),
                                new GraphRequest.GraphJSONObjectCallback() {
                                    @Override
                                    public void onCompleted(
                                            JSONObject jsonObject,
                                            GraphResponse response) {
                                        try {
                                            email = jsonObject.getString("email");
                                            gender = jsonObject.getString("gender");
                                            if (mAuthTask == null) {
                                                mAuthTask = new UserLoginTask(email, "", profile.getName(), "facebook",profile.getId(),loginResult.getAccessToken().getToken(),gender,getRegistrationId(getApplicationContext()));
                                                //Log.v("token", loginResult.getAccessToken().getToken());
                                                mAuthTask.execute((Void) null);
                                            }

                                        } catch (JSONException exe) {

                                        }
                                    }
                                });
                        Bundle parameters = new Bundle();
                        parameters.putString("fields", "id,name,link,email,gender");
                        request.setParameters(parameters);
                        request.executeAsync();
                    }

                    @Override
                    public void onCancel() {
                        LoginManager.getInstance().logOut();
                    }

                    @Override
                    public void onError(FacebookException exception) {
                        LoginManager.getInstance().logOut();
                    }
                });
        mGoogleApiClient = buildGoogleApiClient();
        if (savedInstanceState != null) {
            mSignInProgress = savedInstanceState
                    .getInt(SAVED_PROGRESS, STATE_DEFAULT);
        }
        setContentView(R.layout.activity_main);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case RC_SIGN_IN:
                if (resultCode == RESULT_OK) {
                    // If the error resolution was successful we should continue
                    // processing errors.
                    mSignInProgress = STATE_SIGN_IN;
                } else {
                    // If the error resolution was not successful or the user canceled,
                    // we should stop processing errors.
                    mSignInProgress = STATE_DEFAULT;
                }

                if (!mGoogleApiClient.isConnecting()) {
                    // If Google Play services resolved the issue with a dialog then
                    // onStart is not called so we need to re-attempt connection here.
                    mGoogleApiClient.connect();
                }
                break;
        }





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Meetup on behalf of GIRIDHAR BM from The Bangalore Android User Group - [ B.A.U.G ].
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

People in this
group are also in: