title: How to set a fixed time if AsyncTask is not finished
body: <p>I have an asynctask and I'm looking to do a wait if the async is taking too long,  I'm downloading some data of the database , but I don't want to have the user looping around the progressdialog, I want to set a fixed time, lets say I'm downloading a file but is taking forever, so I tell the user, "hey, check your internet connection and try again" I'm looking to do this with a timer, but I'm kinda stuck, this is where I do my asynctask</p>
  
  <pre><code>private class DownloadFilesTask extends AsyncTask&lt;Void, Void, Void&gt; {
               String s;
               public DownloadFilesTask(String s){
                   this.s = s;
               }
  
               @Override
               protected Void doInBackground(Void... voids) {
                   DownloadMethod(s);
                   return null;
               }
           }
  </code></pre>
  
  <p>so let's say I want to execute that downloadmethod for a fixed time, 10 or 20 seconds, if the file is not downloaded at that time I return a message to the user saying that he needs to check for hes internet.</p>