Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I occasionally have a toast notification that is too long to read in the given amount of time that it is displayed. Is there any way to change the length of time these notifications display?

Also, is there any way to view these notifications after they are gone? This would be ideal, like an app or a folder that logs all the toast notifications where I can review them later.

share|improve this question
add comment

4 Answers 4

up vote 6 down vote accepted

I love it when I can give these answers ;)

Simple Answer: No, this isn't possible.

Long Answer:

Toasts are built into apps, and are low level. There is no way for 3rd party apps to catch toasts, and there is no way to view them longer.

This could be possible if you made your own custom ROM however.

share|improve this answer
add comment

The values of LENGTH_SHORT and LENGTH_LONG are 0 and 1. This means they are treated as flags rather than actual durations so I don't think it will be possible to set the duration to anything other than these values.

If you want to display a message to the user for longer, consider a Status Bar Notification. Status Bar Notifications can be programmatically cancelled when they are no longer relevant.

share|improve this answer
add comment

No, however some apps lets you set a time that a toast message stays on screen.

(...I think.)

share|improve this answer
    
What apps? I find this hard to believe, since the code used to show toasts has only two constants for the duration, Toast.LENGTH_SHORT and Toast.LENGTH_LONG. The entire Toast class would need to be overridden to allow custom lengths. –  onik Aug 23 '13 at 5:31
2  
@onik - Some devs create their own Dialog implementations that mimic toasts both functionally and visually, but with custom timings. Not a true toast, but the end-user doesn't know that. –  aggregate1166877 Aug 23 '13 at 11:08
add comment

YES, you can. Everything is possible. Just call the toast multiple times in the code. I put the toast code in a method, and I call that method 3 times back to back to back. Toast stays on the screen for a good amount of time, and i get the visually effect I want. simple, works for me.

public class Image extends Activity {

ImageView image;
String sceneUrl;
String networkAvatar;

protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.image);
   Intent intent = getIntent();
   String networkAvatar = intent.getStringExtra("networkAvatar");
   customToast("hey", cool);
   customToast("hey", cool);
   customToast("hey", cool);
 }

   private void customToast(String message, String avatar) {
     LayoutInflater li = getLayoutInflater();
     View toastLayout = li.inflate(R.layout.toast, (ViewGroup)findViewById
             (R.id.toastLayout));
     ImageView imageToast = (ImageView) toastLayout.findViewById(R.id.toastImage);
     Picasso.with(this).load(avatar).into(imageToast);
     TextView text = (TextView) toastLayout.findViewById(R.id.toastText);
     text.setText(message);
     Toast toast = new Toast(this);
     toast.setDuration(Toast.LENGTH_LONG);
     toast.setView(toastLayout);
     toast.setGravity(Gravity.FILL_HORIZONTAL|Gravity.BOTTOM|Gravity.RIGHT,100,50);
     toast.show();
 }

If it's gonna leak memory or cause my user's phone to blowup someone please let me know.

share|improve this answer
    
Welcome to the site! Android Enthusiasts is not a site for discussing Android Development, yet your answer assumes that this is a development question. The asker of this question wasn't asking how to make Toasts from his own application last longer, he was asking how to make them last longer for other apps. You may also want to read our help center for more information about what we handle here. Also calling toasts multiple times may not break things, but many would consider it bad practice. –  dotVezz Jan 9 at 19:56
    
bad practice is my new slogan –  sirvon Jan 10 at 6:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.