title: Android Toast started from Service only displays once
body: <p>I have a service that monitors a socket connection.  When the connection is lost it needs to display a Toast informing the user that it is reconnecting.  This works fine the first time.  After that I see the enqueueToast in the log but the toast is not displayed.  Any ideas are appreciated.  I thought this was going to be an easy thing to add, but I must be missing something.</p>
  
  <p>Log entry</p>
  
  <blockquote>
    <p>INFO/NotificationService(118): enqueueToast pkg=com.abc
    callback=android.app.ITransientNotification$Stub$Proxy@43f7b100
    duration=1</p>
  </blockquote>
  
  <p>Code that calls the Toast</p>
  
  <pre><code>public class ConnectionService extends Service 
  { .....
  
  public void restartConnection()
  {
    try
    {
       Log.i(this.toString(), "Attempting to reconnect...");
  
       // increase the wait between each retry until the max is reached
       int sleepTime = reconnectCounter * MIN_RECON_WAIT;
  
       if (sleepTime &gt; MAX_RECON_WAIT)
       {
          sleepTime = MAX_RECON_WAIT;
       }
  
       String msg = "The connection has been lost.  Restart attempt will start in: " + sleepTime/1000 + " seconds";
  
       Log.i(this.toString(), msg);
       Toast.makeText(getApplicationContext(), msg , Toast.LENGTH_LONG).show();
  
       Thread.sleep(sleepTime);
  
       // increment the counter
       reconnectCounter++;
  
       this.startConnectionThread();
  
    }
    catch (Exception e)
    {
        Log.e(this.toString(), "Exception: " + e.toString());
        e.printStackTrace();
    }
  }// end retartConnection
  </code></pre>