tags:

views:

22

answers:

1

Hi i want to execute one method and take some time and then ececute run another method.Is there any possibility for this in handler .Give me some suggestions.Thanks in advance. I am using the below code in handlers but it is not working properly.

            RefreshHandler extends Handler {


    public void handleMessage(Message msg) {            
        FirstLevelMaths.this.updateUI();
        FirstLevelMaths.this.updateUI1();
    }

    public void sleep(long delayMillis) {

        this.removeMessages(0);         
        if(isUpdateUI)
            sendMessageDelayed(obtainMessage(0), delayMillis);
    }

}

 private void updateUI(){
    try
    {
        getimages();
        mRedrawHandler.sleep(5000);

    }
    catch (Exception e) {
        e.printStackTrace();
    }
    finally
    {
            System.gc();
            System.runFinalization();
    }
}

public void updateUI1() { try { getimages1(); mRedrawHandler.sleep(5000);

}
catch (Exception e) {
    e.printStackTrace();
}
finally
{
        System.gc();
        System.runFinalization();
}

}

 public void updateUI1() {
try
{
    getimages1();
    mRedrawHandler.sleep(5000);

}
catch (Exception e) {
    e.printStackTrace();
}
finally
{
        System.gc();
        System.runFinalization();
}

}

I this getImages() and getimages1() are two methods

+1  A: 

You can set Thread.sleep() between 2 methods. Or if you want to start on e method after another, you can use join() of Thread.

Nishant Shah
Thank u for your response.Please give me some sample code
sairam
In your class :class Test { // Call First method Thread.sleep(2000); // Call Second method}
Nishant Shah