title: How to create a dialog inside onResponse method?
body: <p>Here is my dialog code</p>
  
  <pre><code>public void registrationSuccess(final Context context, String warning, String message) {
          alert = new AlertDialog.Builder(context);
          alert.setTitle(warning);
          alert.setMessage(message)
                  .setCancelable(false)
                  .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                          Intent i = new Intent(context, loginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                          context.startActivity(i);
                      }
                  });
          AlertDialog alertDialog = alert.create();
          alert.show();
      }
  </code></pre>
  
  <p>and I want to use it inside my onResponse method below</p>
  
  <pre><code>client.newCall(request).enqueue(new Callback() {
          @Override
          public void onFailure(Call call, IOException e) {
              System.out.println("Failure!!");
          }
  
          @Override
          public void onResponse(Call call, Response response) throws IOException {
              if(response.isSuccessful()) {
                  registrationSuccess(getApplicationContext(), getResources().getString(R.string.congrats), getResources().getString(R.string.successfull_registration));
              } else {
                  System.out.println("FAILED");
  
              }
          }
  
      });
  </code></pre>
  
  <p>getApplicationContext breaks the app with the following error showing in the console</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
  </code></pre>
  
  <p>With what should I replace <code>context</code>?</p>
  
  <p>NOTE: its non-activity class</p>