This is the way I have to show the Toast for 500 milliseconds. Though, it\'s showing more than a second.
Toast.makeText(LiveChat.this, \"Typing\
This one is working fine for me.
final Toast mToastToShow;
int toastDurationInMilliSeconds = 10000;
mToastToShow = Toast.makeText(getApplicationContext(), "Snapshot Saved Successfully.",Toast.LENGTH_LONG);
// Set the countdown to display the toast
CountDownTimer toastCountDown;
toastCountDown = new CountDownTimer(toastDurationInMilliSeconds, 1000 /*Tick duration*/) {
public void onTick(long millisUntilFinished) {
mToastToShow.show();
}
public void onFinish() {
mToastToShow.cancel();
}
};
// Show the toast and starts the countdown
mToastToShow.show();
toastCountDown.start();
the countdown is used to display a toast message for a specific duration.