title: AlertDialog Issue On Android 4.1
body: <p>I get some error working with alert dialog. I use 4.1 jelly bean sdk. I want to check user's internet connection and gps is available or not. </p>
  
  <p>Error Line:</p>
  
  <pre><code>myAlertDialog = alertDialog.create();
  </code></pre>
  
  <p>My control function:</p>
  
  <pre><code>public void kontrol(){
  
              LocationManager locManager = (LocationManager) getSystemService(LOCATION_SERVICE);  
  
              if (locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){  
  
                  if(isConn()){
  
                  {   
                      startActivity(new Intent (MainActivity.this,GPSanasayfa.class));
                  }
              }
                  else{
                      AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);
  
                      alertDialog.setMessage("Uygulamayı kullanabilmek için internet bağlantınızın aktif olması gerekmektedir");
                      alertDialog.setPositiveButton("Tamam", new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int which) {
                            System.exit(0);
                         }
                      });
  
                      myAlertDialog = alertDialog.create(); //I get error this line
                      myAlertDialog.show();
                  }
  
          }
  
              else{
                      startActivity(new Intent (MainActivity.this,NormalAnasayfa.class)); 
              }
  
          }
  </code></pre>
  
  <p>Error Log:</p>
  
  <pre><code>09-12 09:06:28.685: E/AndroidRuntime(825): FATAL EXCEPTION: Thread-93
  09-12 09:06:28.685: E/AndroidRuntime(825): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
  09-12 09:06:28.685: E/AndroidRuntime(825):  at android.os.Handler.&lt;init&gt;(Handler.java:121)
  09-12 09:06:28.685: E/AndroidRuntime(825):  at android.app.Dialog.&lt;init&gt;(Dialog.java:107)
  09-12 09:06:28.685: E/AndroidRuntime(825):  at android.app.AlertDialog.&lt;init&gt;(AlertDialog.java:114)
  09-12 09:06:28.685: E/AndroidRuntime(825):  at android.app.AlertDialog$Builder.create(AlertDialog.java:913)
  09-12 09:06:28.685: E/AndroidRuntime(825):  at com.minor.cepcadisiv3.MainActivity.kontrol(MainActivity.java:55)
  09-12 09:06:28.685: E/AndroidRuntime(825):  at com.minor.cepcadisiv3.MainActivity$2.run(MainActivity.java:78)
  09-12 09:06:28.685: E/AndroidRuntime(825):  at java.lang.Thread.run(Thread.java:856)
  </code></pre>
  
  <p>I call this function in onCreate:</p>
  
  <pre><code>@Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          pdialog = ProgressDialog.show(MainActivity.this, "Kontrol Ediliyor...", "İnternet ve GPS erişiminiz kontrol ediliyor.",true);
  
          new Thread(new Runnable() {  
              public void run() { 
                  try {
                      Thread.sleep(2000);
                      kontrol(); 
                      pdialog.dismiss();
                  } catch (InterruptedException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
                  return;  
              }  
          }).start();  
  
  }
  </code></pre>