title: AsyncTask on Android stops working after 2-5 minutes
body: <p>Currently building an Android app and checking it on Genymotion running 4.1.1. I'm using <code>AsyncTask</code> to call the Bing Translate API to translate from text:</p>
  
  <pre><code>class TranslateFacebookText extends AsyncTask&lt;String, Integer, String&gt; {
      @Override
      protected String doInBackground(String... message) {
          String translatedText = "";
          try {
              translatedText = Translate.execute(message[0], Language.AUTO_DETECT, Language.ENGLISH);
          } catch (Exception e) {
              ....
          }
          return translatedText;  
      }
  
      @Override
      protected void onPostExecute(String translatedText) {
          message = translatedText;
          confirmTTSData();
      }
  }
  
  public void onClick(View src) {
      TranslateFacebookText translateTask = new TranslateFacebookText();
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
          translateTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, message);
      }
      else {
          translateTask.execute(message);
      }
  }
  </code></pre>
  
  <p>I'm using this method to start the task after reading this question: <a href="https://stackoverflow.com/questions/9119627/android-sdk-asynctask-doinbackground-not-running-subclass">Android SDK AsyncTask doInBackground not running (subclass)</a></p>
  
  <p>I'm doing so, since after about 2-5 minutes from the programs start, the <code>AsyncTask</code> refuses to run. That is, <code>doInBackground</code> does not get called, nor does <code>onPostExecute</code>. the <code>onClick</code> DOES get called, creates the new AsyncTask and runs the execution code, but the <code>doInBackground</code> does not get called.</p>
  
  <p>This is completely random. I'm not doing anything else - just waiting there for a couple of minutes, and afterwards clicking the button again to see this happen. This is also true with a service which runs every specified time using a <code>Handler</code> and <code>postDelayed</code>. Here's an example:</p>
  
  <pre><code>public class MyService extends Service {
      private Handler periodicEventHandler;
      private final int PERIODIC_EVENT_TIMEOUT = 600000;
  
      @Override
      public void onCreate() {
          periodicEventHandler = new Handler();
          periodicEventHandler.postDelayed(doPeriodicTask, PERIODIC_EVENT_TIMEOUT);
      }
  
      private Runnable doPeriodicTask = new Runnable()
      {
          public void run()
          {
              TranslateFacebookText translateTask = new TranslateFacebookText();
              if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
                  translateTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, message);
              }
              else {
                  translateTask.execute(message);
              }
              periodicEventHandler.postDelayed(doPeriodicTask, PERIODIC_EVENT_TIMEOUT);
          }
      };
  
      class TranslateFacebookText extends AsyncTask&lt;String, Integer, String&gt; {
          @Override
          protected String doInBackground(String... message) {
              String translatedText = "";
              try {
                  translatedText = Translate.execute(message[0], Language.AUTO_DETECT, Language.ENGLISH);
              } catch (Exception e) {
                  ....
              }
              return translatedText;  
          }
  
          @Override
          protected void onPostExecute(String translatedText) {
              message = translatedText;
              confirmTTSData();
          }
      }
  }
  </code></pre>
  
  <p>The <code>doPeriodicTask</code> runs fine, again creating the AsyncTask and calling the execution code, but <code>doInBackground</code> never gets called. If I change <code>PERIODIC_EVENT_TIMEOUT</code> to 8000, for example, <code>doInBackground</code> would get called fine.</p>
  
  <p>Ideas?</p>