开发者

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

开发者 https://www.devze.com 2023-03-08 02:05 出处:网络
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 runn

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

精彩评论

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