A very simple approach to creating a slightly longer message is as follows:
private Toast myToast;
public MyView(Context context) {
myToast = Toast.makeText(getContext(), "", Toast.LENGTH_LONG);
}
private Runnable extendStatusMessageLengthRunnable = new Runnable() {
@Override
public void run() {
//Show the toast for another interval.
myToast.show();
}
};
public void displayMyToast(final String statusMessage, boolean extraLongDuration) {
removeCallbacks(extendStatusMessageLengthRunnable);
myToast.setText(statusMessage);
myToast.show();
if(extraLongDuration) {
postDelayed(extendStatusMessageLengthRunnable, 3000L);
}
}
Note that the above example eliminates the LENGTH_SHORT option to keep the example simple.
You will generally not want to use a Toast message to display messages for very long intervals, as that is not the Toast class' intended purpose. But there are times when the amount of text you need to display could take the user longer than 3.5 seconds to read, and in that case a slight extension of time (e.g., to 6.5 seconds, as shown above) can, IMO, be useful and consistent with the intended usage.