title: how to call a fragment method in an activity
body: <p>I have a dialog method in my fragment, which I want to call from my main activity FAB.</p>
  
  <p>I tried to call it, but got this error; </p>
  
  <pre><code>Attempt to invoke virtual method 'android.view.LayoutInflater android.support.v4.app.FragmentActivity.getLayoutInflater()' on a null object reference
  </code></pre>
  
  <p>editProfileDialog() is the dialog method in my fragment that I tried to call in my main activity.</p>
  
  <pre><code>public class Edit_fragment extends Fragment {
  
  private EditPresenter mEditPresenter;
  
  public Edit_fragment() {
      // Required empty public constructor
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      View view = inflater.inflate(R.layout.edit_profile_fragment, container, false);
      ButterKnife.bind(this, view);
  
      mEditPresenter = new EditPresenter(this);
      mEditPresenter.onCreate();
  
      return view;
  }
  
  
  public void editProfileDialog(){
      LayoutInflater inflater = getActivity().getLayoutInflater();
      View dialoglayout = inflater.inflate(R.layout.edit_profile_dialogue, null);
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setView(dialoglayout);
      builder.setCancelable(true);
  
      TextView edit_profile = (TextView)dialoglayout.findViewById(R.id.edit_me);
      Typeface Sms = Typeface.createFromAsset(getActivity().getAssets(), "fonts/FTLTLT.TTF");
      edit_profile.setTypeface(Sms);
  
      TextView new_profile_photo = (TextView)dialoglayout.findViewById(R.id.addAvatar);
      new_profile_photo.setTypeface(Sms);
  
  
      TextView edit_username = (TextView)dialoglayout.findViewById(R.id.editUsernameBtn);
      edit_username.setTypeface(Sms);
  
      TextView Change_bio = (TextView)dialoglayout.findViewById(R.id.statusLayout);
      Change_bio.setTypeface(Sms);
  
      final AlertDialog dialog = builder.create();
  
      new_profile_photo.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View view) {
              dialog.dismiss();
              editPhotoDialog();
          }
      });
  
      edit_username.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View view) {
              dialog.dismiss();
  
          }
      });
  
      Change_bio.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View view) {
              dialog.dismiss();
  
          }
      });
  
  
      dialog.show();
  }
  
  private void editPhotoDialog(){
      LayoutInflater inflater = getActivity().getLayoutInflater();
      View dialoglayout = inflater.inflate(R.layout.edit_photo_dialogue, null);
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setView(dialoglayout);
      builder.setCancelable(true);
  
      FrameLayout cameraBtn = (FrameLayout)dialoglayout.findViewById(R.id.cameraBtn);
  
      FrameLayout galleryBtn = (FrameLayout)dialoglayout.findViewById(R.id.galleryBtn);
  
      AppCompatTextView cameraBtnTxt = (AppCompatTextView)dialoglayout.findViewById(R.id.cameraBtnTxt);
      Typeface Sms = Typeface.createFromAsset(getActivity().getAssets(), "fonts/FTLTLT.TTF");
      cameraBtnTxt.setTypeface(Sms);
  
  
      AppCompatTextView galleryBtnText = (AppCompatTextView)dialoglayout.findViewById(R.id.galleryBtnText);
      galleryBtnText.setTypeface(Sms);
  
      final AlertDialog dialog = builder.create();
  
      cameraBtn.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View view) {
              dialog.dismiss();
              setCameraBtn();
          }
      });
  
      galleryBtn.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View view) {
              dialog.dismiss();
              setGalleryBtn();
          }
      });
  
      dialog.show();
  }
  
  private void setGalleryBtn() {
      if (PermissionHandler.checkPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)) {
          AppHelper.LogCat("Read data permission already granted.");
          new PickerBuilder(getActivity(), PickerBuilder.SELECT_FROM_GALLERY)
                  .setOnImageReceivedListener(imageUri -&gt; {
                      Intent data = new Intent();
                      data.setData(imageUri);
                      AppHelper.LogCat("new image SELECT_FROM_GALLERY" + imageUri);
                      mEditPresenter.onActivityResult(this, AppConst.SELECT_PROFILE_PICTURE, RESULT_OK, data);
  
                  })
                  .setImageName(getActivity().getString(R.string.app_name))
                  .setImageFolderName(getActivity().getString(R.string.app_name))
                  .setCropScreenColor(R.color.colorPrimary)
                  .withTimeStamp(false)
                  .setOnPermissionRefusedListener(() -&gt; {
                      PermissionHandler.requestPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE);
                  })
                  .start();
  
      } else {
          AppHelper.LogCat("Please request Read data permission.");
          PermissionHandler.requestPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE);
      }
  
  }
  
  
  
  private void setCameraBtn() {
      if (PermissionHandler.checkPermission(getActivity(), Manifest.permission.CAMERA)) {
          AppHelper.LogCat("camera permission already granted.");
          new PickerBuilder(getActivity(), PickerBuilder.SELECT_FROM_CAMERA)
                  .setOnImageReceivedListener(imageUri -&gt; {
  
                      AppHelper.LogCat("new image SELECT_FROM_CAMERA " + imageUri);
                      Intent data = new Intent();
                      data.setData(imageUri);
                      mEditPresenter.onActivityResult(this, AppConst.SELECT_PROFILE_CAMERA, RESULT_OK, data);
  
                  })
                  .setImageName(getActivity().getString(R.string.app_name))
                  .setImageFolderName(getActivity().getString(R.string.app_name))
                  .setCropScreenColor(R.color.colorPrimary)
                  .withTimeStamp(false)
                  .setOnPermissionRefusedListener(() -&gt; {
                      PermissionHandler.requestPermission(getActivity(), Manifest.permission.CAMERA);
                  })
                  .start();
      } else {
          AppHelper.LogCat("Please request camera  permission.");
          PermissionHandler.requestPermission(getActivity(), Manifest.permission.CAMERA);
      }
  }
  
  }
  </code></pre>
  
  <p>On my fab.setOnClickListener() that is in my main_activity. I called editProfileDialog() like this;</p>
  
  <pre><code>mEdit_profile_fragment.editProfileDialog();
  </code></pre>
  
  <p>AND THAT ERROR SHOWED UP IN THE LOGCAT.</p>