how to implement uihandlers running one after one in android
<p>hi i am kid application  i am using uihandler display images using gallery and image view 
in gallery scrolling  one method running automatically apply handler another one onitem selection clicked event this two events are developing code my problem is at a time one event are fire how to implement </p>

<p>this on item selection event</p>

<p>g.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View v, final int position, long id) 
            {
                // mRedrawHandler.handleMessage(new Message());<br>
                isUpdateUI = false;
                new Timer().schedule(new TimerTask() 
                {
                @Override
                    public void run()
                    {</p>

<pre><code>            try {

                imageid=position;
                ((ImageView)findViewById(R.id.ImageViewlarge)).setImageResource(mImageIds[position]);
                ((TextView)findViewById(R.id.TextViewImageName)).setText(imgNames[position]);

                    } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                }
                    },  2);

             isUpdateUI = true; 
             mRedrawHandler.handleMessage(new Message());  
            }
</code></pre>

<p>this code for update handler</p>

<pre><code>protected void onStart() {
super.onStart();

    imageid=getSharedPreferences("ResultInfo", 0).getInt("Result", 0);
    Log.v("Gallary","Imageid"+imageid);
    isUpdateUI = true;
    mRedrawHandler.handleMessage(new Message());

} 
protected void onPause()
{
    super.onPause();
    isUpdateUI = false;
}

 class RefreshHandler extends Handler {


    @Override
    public void handleMessage(Message msg) {            
        KidsSpell.this.updateUI();
    }

    public void sleep(long delayMillis) {

        this.removeMessages(0);         
        if(isUpdateUI)
            sendMessageDelayed(obtainMessage(0), delayMillis);
    }
</code></pre>

<p>}
public void updateUI(){
    try
    {
           getImages();//rotation method
        mRedrawHandler.sleep(2000);</p>

<pre><code>}
catch (Exception e) {
    e.printStackTrace();
}
</code></pre>

<p>gallery automatically scrolling every 2sec using handler its working fine problem is gallery items scrolling then stop handler then activity finish after continue the handler how can implemented  please some solution i am new in android its urgent</p>
