I want To know how can I Toast The Message or String after 5 seconds In Android..? Suggest Some Solutions or Code..
Toast.makeText(Getapplicationcontext,"Hello", Toast.length_Short);
I have Simple code can anybody have idea..?
I want To know how can I Toast The Message or String after 5 seconds In Android..? Suggest Some Solutions or Code..
Toast.makeText(Getapplicationcontext,"Hello", Toast.length_Short);
I have Simple code can anybody have idea..?
I am assuming you want to show Toast after 5 seconds when your activity is open, you have to use Handler class
for that checkout below code -
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Toast.makeText(getContext(), "Hello", Toast.LENGTH_SHORT).show();
}
}, 5000);
where 5000 is time in milliseconds.
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// Add the line which you want to run after 5 sec.
}
},5000);