best is :
if(m_Toolbar.getVisibility() == View.VISBILE) {
...........
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
m_Toolbar.setVisibility(View.GONE);
}
}, 5000);//5 seconds
}
But if you need multiply actions you can use this:
if(m_Toolbar.getVisibility() == View.VISBILE) {
int Delay = 5; //set Your request delay
new Thread(new Runnable(){
public void run() {
// TODO Auto-generated method stub
do{
try {
runOnUiThread(new Runnable() {
public void run() {
Delay --;
if( Delay == 0){
m_Toolbar.setVisibility(View.GONE);
}else if( Delay == 1){
//another action
}
}
});
Thread.sleep(1000);
} catch (InterruptedException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
}while(Delay > 0);
}
}).start();
}