AsyncTask issues
<p>I've got following code in my AsyncTask. The only thing I want the AsyncTask to do, is to sleep for 1000 ms, while showing a ProgressDialog. </p>

<pre><code>package something.something.Logic;

import android.R;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

public class DeviceScan extends AsyncTask&lt;String, Void, String&gt; {

ProgressDialog dialog;
Context _context; 

public DeviceScan(Context context) {    
    _context = context; 
    dialog = new ProgressDialog(_context);  
}

protected void onPreExecute() {

      dialog = new ProgressDialog(_context);
      dialog.setTitle("Please Wait");
      dialog.setMessage("Searching for devices..");
      dialog.setIndeterminate(true);
      dialog.setCancelable(false);
      dialog.show();    
}

@Override
protected String doInBackground(String... params) {

      for(int i=0;i&lt;5;i++) {

        try {
            Thread.sleep(1000);

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
      }

      return "";
}

 protected void onPostExecute(Integer result) {

     /*
      * When the background thread is finished, do something here
      */
     Toast.makeText(_context, "Done!!", Toast.LENGTH_LONG).show(); 
     dialog.dismiss(); 
 }
}
</code></pre>

<p>Then I call the AsyncTask this way:</p>

<pre><code>import something.something.Logic.*;

public void onClick(View view){

    switch(view.getId())    {

        case R.id.button1:
            new DeviceScan(getApplicationContext()).execute("");
      break;

    }
}
</code></pre>

<p>But my app just crashes when I hit the button, I cant find any information from the debugger. Can anyone give me a hint?</p>

<p>Thanks in advance.</p>
