开发者

how can implemented two methods implement one after one need some time using uihandlers

i am implementing one chat messages related application in this main activity call one method and second method every ten seconds refreshing this method applied ui handler refreshing purpose both running at same time my intension is one method call some time and refresh applied second method call some time initally activity first time only how can implement time delay in both methods

first method :

Handler handlerTimer = new Handler();

handlerTimer.postDelayed(new Runnable()
{
public void run()
{
handlerMessage("",0);

}}, 2000);

second method:

 class RefreshHandler extends Handler 
     {
        public void handleMessage(Message msg)
         {
            Main.this.updateUI();
         }
         public void sleep(long delayMil开发者_JAVA百科lis) {
            this.removeMessages(0);
            if(isUpdateUI  )

          sendMessageDelayed(obtainMessage(0), delayMillis);
         }
         };
         private void updateUI()
              {
                handlerreferesh("",0);//this second method 

        }

        mRedrawHandler.sleep(10000);
         }
         }

first method initially call 2 sec after second refresh call some time how can implemented plaese forawrd some valuable suggestion thanks in advance


Use one thread with one handler for the first method and another thread with another handler for second method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜