title: How to show an AlertDialog in class which extends Application
body: <p>I have a class which extends Application. 
  The goal is to show an AlertDialog (with 1 OK button), immediately after the apllication begins and only then (every time the user runs the app, but <strong>not</strong> every time the user enter to the main Activity from other Activities ).</p>
  
  <p>The name of the main Activity is Activity1.</p>
  
  <p>So here is the class  which extends Application:</p>
  
  <pre><code>   public class MyApp extends Application {
          @Override
          public void onCreate() {
              super.onCreate();
  
              Activity1 myActivity1=new Activity1();
  
              AlertDialog.Builder builder = new AlertDialog.Builder(myActivity1);
               builder.setMessage("Hello").setCancelable(false).setPositiveButton("OK",                                                                   new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int id) {
                      //do things
                 }
              });
              AlertDialog alert = builder.create();
              alert.show();
          }
      }
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to create application…...NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
  </code></pre>
  
  <p>I guess activity1 is not the right argument. I tried the "this" argument also. I mean:</p>
  
  <pre><code>AlertDialog.Builder builder = new AlertDialog.Builder(this);
  </code></pre>
  
  <p>It also didn't help.</p>
  
  <p>If someone has any idea about this, I'll appreciate the help. Thank you!</p>