title: Android - Dialog getSupportFragmentManager undefined
body: <p>I'm trying to implement a simple Dialog into my code. But it does not work. I have searched every available tutorial, including the official developer guide but nothing works. The error I got from logcat is that I'm getting a nullPointerException, I'm guessing that's on the getActivity. Any help?</p>
  <p>This is what I have: This is my Custom Dialog class.</p>
  <pre><code>public class SaveDialog extends DialogFragment {
  
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
          builder.setTitle(&quot;Save Password&quot;);
          builder.setView(getContentView());
          Dialog dialog = builder.create();
          dialog.show();
          return dialog;
      }
  
      private View getContentView() {
          LayoutInflater inflater = getActivity().getLayoutInflater();
      
          return inflater.inflate(R.layout.dialog, null);
      }
  }
  </code></pre>
  <p>and this is my main activity where the onclick occurs</p>
  <pre><code>private void savePassword() {
      SaveDialog savePasswordDialog = new SaveDialog();
      savePasswordDialog.show(savePasswordDialog.getSupportFragmentManager(), &quot;tag&quot;);
  }
  </code></pre>
  <p>Every single time I fire up the onClick, the app crashes. On top of that, currently I am trying to use getSupportFragmentManager, but it says it's undefined.</p>