title: NullPointer with using Facebook SDK
body: <p>I using Facebook SKD in my app and I have next error:</p>
  
  <p>My <code>callBackmanager</code> in <code>onActivityResult()</code> method is null and I get <code>NullPointerException</code></p>
  
  <p>This is my code:</p>
  
  <pre><code>parent.findViewById(R.id.fb_login_button).setOnClickListener(this);
  </code></pre>
  
  <p>Where
  <code>R.id.fb_login_button</code> - my custom button for fb.</p>
  
  <p>When I click this button, my listener call this method:</p>
  
  <pre><code>private void onFacebookButtonClick() {
  
      initFacebook(getView());
      mFacebookLoginButton.performClick(); // this is button from SDK, Visibility - GONE
  }
  </code></pre>
  
  <p>And this <code>initFacebook(View parent)</code> method:</p>
  
  <pre><code>callbackManager = CallbackManager.Factory.create();
  
  mFacebookLoginButton = (LoginButton) parent.findViewById(R.id.login_button);
  mFacebookLoginButton.setReadPermissions("public_profile");
  mFacebookLoginButton.setFragment(this);
  mFacebookLoginButton.registerCallback(callbackManager, new FacebookCallback&lt;LoginResult&gt;() {
      @Override
      public void onSuccess(LoginResult loginResult) {
  
          String userId = loginResult.getAccessToken().getUserId();
          trySocialLogin(userId, Constants.PROVIDER_FACEBOOK);
      }
  
      @Override
      public void onCancel() {
          Log.e("FB", "onCancel()");
      }
  
      @Override
      public void onError(FacebookException exception) {
          exception.printStackTrace();
      }
  });
  </code></pre>
  
  <p>And this code from <code>onActivityResult()</code>:</p>
  
  <pre><code>callbackManager.onActivityResult(requestCode, resultCode, data); // callbackManager is null here - why?
  </code></pre>
  
  <p>Add logcat:</p>
  
  <pre><code>    Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.nashkvartal/com.nashkvartal.StartScreenActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=129742, result=0, data=null} to activity {com.nashkvartal/com.nashkvartal.StartScreenActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.facebook.CallbackManager.onActivityResult(int, int, android.content.Intent)' on a null object reference
         at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3287)
         at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3318)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2661)
         at android.app.ActivityThread.access$800(ActivityThread.java:178)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512)
         at android.os.Handler.dispatchMessage(Handler.java:111)
         at android.os.Looper.loop(Looper.java:194)
         at android.app.ActivityThread.main(ActivityThread.java:5691)
         at java.lang.reflect.Method.invoke(Method.java)
         at java.lang.reflect.Method.invoke(Method.java:372)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
  Caused by java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=129742, result=0, data=null} to activity {com.nashkvartal/com.nashkvartal.StartScreenActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.facebook.CallbackManager.onActivityResult(int, int, android.content.Intent)' on a null object reference
         at android.app.ActivityThread.deliverResults(ActivityThread.java:3887)
         at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3269)
         at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3318)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2661)
         at android.app.ActivityThread.access$800(ActivityThread.java:178)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512)
         at android.os.Handler.dispatchMessage(Handler.java:111)
         at android.os.Looper.loop(Looper.java:194)
         at android.app.ActivityThread.main(ActivityThread.java:5691)
         at java.lang.reflect.Method.invoke(Method.java)
         at java.lang.reflect.Method.invoke(Method.java:372)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
  Caused by java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.facebook.CallbackManager.onActivityResult(int, int, android.content.Intent)' on a null object reference
         at com.nashkvartal.fragments.LoginFragment.onActivityResult(LoginFragment.java:105)
         at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:176)
         at com.nashkvartal.StartScreenActivity.onActivityResult(StartScreenActivity.java:74)
         at android.app.Activity.dispatchActivityResult(Activity.java:6344)
         at android.app.ActivityThread.deliverResults(ActivityThread.java:3883)
         at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3269)
         at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3318)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2661)
         at android.app.ActivityThread.access$800(ActivityThread.java:178)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512)
         at android.os.Handler.dispatchMessage(Handler.java:111)
         at android.os.Looper.loop(Looper.java:194)
         at android.app.ActivityThread.main(ActivityThread.java:5691)
         at java.lang.reflect.Method.invoke(Method.java)
         at java.lang.reflect.Method.invoke(Method.java:372)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
  </code></pre>
  
  <p><strong>UPD - added onActivityResult() full code</strong></p>
  
  <pre><code>@Override
  public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
  
      if (currentProvider == Constants.PROVIDER_FACEBOOK) {           
          callbackManager.onActivityResult(requestCode, resultCode, data); // I catch NullPointer here
      } 
  
      super.onActivityResult(requestCode, resultCode, data);
  }
  </code></pre>