Skip to content

Getting a Attempt to invoke virtual method 'android.support.v4.app.FragmentManager android.support.v4.app.FragmentActivity.getSupportFragmentManager()' on a null object reference #114

Open
@duartebarbosadev

Description

@duartebarbosadev

Hi
I am trying to close the fragment and go back to my Activity when the user is logged in. So I did:

       private void initSocialNetwork(SocialNetwork socialNetwork){
            getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
        }

The thing is if the user is previosly connect it works like a charm, but if he loggs in it shows this error:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentManager android.support.v4.app.FragmentActivity.getSupportFragmentManager()' on a null object reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions