title: How to update a view on a scheduled period
body: <p>Can some one please tell me how to update a view on a scheduled period. for example every second. </p>
  
  <pre><code>MyService.wm.updateViewLayout(mView, mLayoutParams);
  </code></pre>
  
  <p>Problem that I'm having is when I used a timer it run on different thread and it is not allow me to update the view and give following error. </p>
  
  <blockquote>
    <p>04-08 01:19:35.910: W/dalvikvm(11040): threadid=13: thread exiting
    with uncaught exception (group=0x40a3e1f8) 04-08 01:19:35.910:
    E/AndroidRuntime(11040): FATAL EXCEPTION: Thread-1376 04-08
    01:19:35.910: E/AndroidRuntime(11040):
    android.view.ViewRootImpl$CalledFromWrongThreadException: Only the
    original thread that created a view hierarchy can touch its views.
    04-08 01:19:35.910: E/AndroidRuntime(11040):  at
    android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4039) 04-08
    01:19:35.910: E/AndroidRuntime(11040):    at
    android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:709) 04-08
    01:19:35.910: E/AndroidRuntime(11040):    at
    android.view.View.requestLayout(View.java:12680) 04-08 01:19:35.910:
    E/AndroidRuntime(11040):  at
    android.view.View.setLayoutParams(View.java:8223) 04-08 01:19:35.910:
    E/AndroidRuntime(11040):  at
    android.view.WindowManagerImpl.updateViewLayout(WindowManagerImpl.java:312)
    04-08 01:19:35.910: E/AndroidRuntime(11040):  at
    android.view.WindowManagerImpl$CompatModeWrapper.updateViewLayout(WindowManagerImpl.java:145)
    04-08 01:19:35.910: E/AndroidRuntime(11040):  at
    com.example.MyService.UpdateLayers(TrackerService.java:353)
    04-08 01:19:35.910: E/AndroidRuntime(11040):  at
    com.example.MainActivity$5$1.run(MainActivity.java:219)</p>
  </blockquote>
  
  <p>When I'm trying to update it from the same Activity or service it hangs and not do any thing else. just running in the loop.</p>
  
  <pre><code>while (true) {
      MyService.UpdateLayers();
      try {
          Thread.sleep(1000L);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>So, can you please tell me the correct way to do this or work around to update the layers.</p>