title: Android: Showing a Message for less than 2 seconds
body: <p>I'd like to display a message or notification for a custom amount of time, in this case for less than 2 seconds.</p>
  
  <p>I've tried two approaches, neither of them was really helpfull:
  1. Showing a message via Toast and setting the duration via <code>LENGTH_SHORT</code>, which appearently defines a hardcoded duration of 2 seconds. -> Fail
  2. creating a <code>NotificationCompat.Builder</code> with a <code>SetTicker</code> routine and cancel the notification after a certain amount of time. -> The notification (that I do not really need) disappeares after the given time, but the ticker stays unfortunately for a longer duration. :(</p>
  
  <pre><code>private void SetNotification(CharSequence aCharSeq)
  {
    Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(),
      m_RandNotificationID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
  
    NotificationCompat.Builder builder = new    NotificationCompat.Builder(this).setTicker(aCharSeq)
      .setContentTitle(aCharSeq).setContentText(aCharSeq).setSmallIcon(R.drawable.sound)
      .setContentIntent(contentIntent);
  
    Notification noti = builder.build();
  
    m_NotMan.notify(m_RandNotificationID, noti);
  
    new Timer().schedule(CancelAction, 1000L);
  }
  
  TimerTask CancelAction = new TimerTask()
  {
     public void run()
     {
       m_NotMan.cancel(m_RandNotificationID);
     }
  };
  </code></pre>
  
  <p>Any ideas from you would be helpfull. :)</p>
  
  <p>Happy new year</p>
  
  <p>Chris</p>