title: Threading requires that an application's button be clicked twice
body: <p>I have the following code. submitClick() is triggered when someone clicks the submit button on my application. In the past, submit click would be click once, and all of submitFile() would be carried out. By adding the threading addition to checkContent(), now submitClick has to be clicked twice for all of submitFile() to be completed. Is there any way to make it so that submitFile() finishes (with checkContent()) so the user only has to press my apps submit button?</p>
  
  <p>Thank you in advance.</p>
  
  <pre><code>public void submitClick(View v) throws Exception{
      if (!submitted) { submitFile(); }
  }
  
  public void submitFile() {
      checkContent();
      if (valid) {
          Picasso.with(this).load(imageAddress).into(imagePreview);
          saveImage();
          //sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); //refreshes system to show saved file
          submitted = true;
          submit_but.setText("Encrypt");
      }
  }
  
  private void checkContent() {
      media = null;
      if(URLUtil.isValidUrl(imageAddress)) {
          Thread thread = new Thread() {
              boolean img = false;
              boolean youtube = false;
              public void run() {
                  URLConnection connection = null;
                  try {
                      connection = new URL(imageAddress).openConnection();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
                  String contentType = connection.getHeaderField("Content-Type");
                  img = contentType.startsWith("image/");
                  if(img)
                      media = "image";
                  if (!img) {
                      // Check host of url if youtube exists
                      Uri uri = Uri.parse(imageAddress);
                      if ("www.youtube.com".equals(uri.getHost())) {
                          media = "youtube";
                          youtube = true;
                      }
                  }
                  valid = img || youtube;
              }
          };
          thread.start();
      }
  }
  </code></pre>