title: Android : dialog and NullPointerException
body: <p>I have the first activity that call a dialog from second activity with this code :</p>
  
  <pre><code>public class negozi extends ListActivity implements dati_punti{
  
      private Context context;
      private popup_segnala segnala;
  
          @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.negozi);
          context = this;
                      visual_pop(context);
            }
            public void visual_pop(Context context){
                    segnala = new popup_segnala(context);
                     segnala.showDialog(popup_segnala.OK_INSERT);
            }
  </code></pre>
  
  <p>the second activity, popup_segnala have this code :</p>
  
  <pre><code>public class popup_segnala extends Activity {
  public static final int OK_INSERT = 1;
  private static Context context;
  
  public popup_segnala(Context context) {
     this.context = context;
  }
  @Override
  protected Dialog onCreateDialog(int id) {
     switch(id){
     case OK_INSERT :
          Builder build_insert = createDialog(context,"Dati registrati correttamente. Grazie","Alert");
          build_insert.setPositiveButton("Ok", new DialogInterface.OnClickListener(){
  
               @Override
              public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
             }
               });
        return build_insert.show();       
       }
      return null;
   }
  }
  </code></pre>
  
  <p>Why ??? :-(
  I have this error log: </p>
  
  <blockquote>
    <p>09-06 19:44:35.507: ERROR/AndroidRuntime(1657): 09-06 19:44:35.507:
    ERROR/AndroidRuntime(1657): FATAL EXCEPTION: main 09-06 19:44:35.507:
    ERROR/AndroidRuntime(1657): <strong>java.lang.NullPointerException</strong> 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.app.Activity.getVolumeControlStream(Activity.java:3703) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.app.Dialog.setOwnerActivity(Dialog.java:188) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.app.Activity.onPrepareDialog(Activity.java:2491) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.app.Activity.onPrepareDialog(Activity.java:2515) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.app.Activity.showDialog(Activity.java:2565) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.app.Activity.showDialog(Activity.java:2524) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    it.android.infoconsumatori.negozi.onOptionsItemSelected(negozi.java:65)
    09-06 19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.app.Activity.onMenuItemSelected(Activity.java:2205) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:774)
    09-06 19:44:35.507: ERROR/AndroidRuntime(1657):     at
    com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
    09-06 19:44:35.507: ERROR/AndroidRuntime(1657):     at
    com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
    09-06 19:44:35.507: ERROR/AndroidRuntime(1657):     at
    com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
    09-06 19:44:35.507: ERROR/AndroidRuntime(1657):     at
    com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
    09-06 19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.view.View$PerformClick.run(View.java:9152) 09-06 19:44:35.507:
    ERROR/AndroidRuntime(1657):     at
    android.os.Handler.handleCallback(Handler.java:587) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.os.Handler.dispatchMessage(Handler.java:92) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    android.os.Looper.loop(Looper.java:123) 09-06 19:44:35.507:
    ERROR/AndroidRuntime(1657):     at
    android.app.ActivityThread.main(ActivityThread.java:3687) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    java.lang.reflect.Method.invokeNative(Native Method) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    java.lang.reflect.Method.invoke(Method.java:507) 09-06 19:44:35.507:
    ERROR/AndroidRuntime(1657):     at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
    09-06 19:44:35.507: ERROR/AndroidRuntime(1657):     at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 09-06
    19:44:35.507: ERROR/AndroidRuntime(1657):     at
    dalvik.system.NativeStart.main(Native Method)</p>
  </blockquote>