title: Method my timer is executing keeps failing
body: <p>I am using the Timer Class to execute a function every 2 mins. </p>
  
  <p>The code in my TimerMethod is failing but when it was part of onCreat it worked perfectly. I do notice it is failing when it gets to updating text fields in my layout.</p>
  
  <p>Code is below:</p>
  
  <pre><code>public class MeetingManager extends ListActivity {
  
      private static final String TAG = "MyApp";
      public static final String PREFS_NAME = "MyAppData";
      private Timer myTimer;
  
      /** Called when the activity is first created. */
  
      //private PendingIntent mAlarmSender;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
          WindowManager.LayoutParams.FLAG_FULLSCREEN);
          setContentView(R.layout.main);
  
              myTimer = new Timer();
              myTimer.schedule(new TimerTask() {
                  @Override
                  public void run() {
                      TimerMethod();
                  }
  
                      }, 0, 10000);
  
  
      }
  </code></pre>
  
  <p><strong>in the same class my TimerMethod:</strong></p>
  
  <pre><code>  protected void TimerMethod() {
              Log.d(TAG, "NEW IN TIMER");
              SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
              String items = settings.getString("RoomId", "MISSING");
  
  
               Map&lt;String, String&gt; maproom = new HashMap&lt;String, String&gt;();
               maproom.put("145", "dddd");
               maproom.put("110", "vvvv");
               maproom.put("148", "ddddd");
               maproom.put("45", "Pfgdfgdfgdf");
  
  
               String roomName = maproom.get(items);
  
               Log.d(TAG, roomName);
  
               TextView currentRoomName = (TextView)  this.findViewById(R.id.RoomTitle); 
               currentRoomName.setText(roomName); 
  
               ImageView b=(ImageView)findViewById(R.id.b);
                b.setOnClickListener(listener);
  
  
                  Date anotherCurDate = new Date();
  
                SimpleDateFormat formatter = new SimpleDateFormat("EEEE', 'MMMM dd', ' yyyy");  
                String formattedDateString = formatter.format(anotherCurDate);
  
               TextView currentRoomDate = (TextView)  this.findViewById(R.id.CurrentDate); 
               currentRoomDate.setText(formattedDateString); 
  
       ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
  
              String xml = XMLfunctions.getXML(items);
              Document doc = XMLfunctions.XMLfromString(xml);
  
              /*int numResults = XMLfunctions.numResults(doc);
  
              if((numResults &lt;= 0)){
                  Toast.makeText(MeetingManager.this, "NOT GETTING XML", Toast.LENGTH_LONG).show();  
                  finish();
              } */
  
              Element docElem = doc.getDocumentElement();
              NodeList nodes = (NodeList)docElem.getElementsByTagName("meeting_item");
  
      int node_number = nodes.getLength();
      String node_final = String.valueOf(node_number);
  
              Log.d(TAG, node_final);
  
              for (int i = 0; i &lt; nodes.getLength(); i++) {                           
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();    
  
                  Element e = (Element)nodes.item(i);
  
                          map.put("time", XMLfunctions.getValue(e, "time"));
                          map.put("endtime", XMLfunctions.getValue(e, "endtime"));
                          map.put("name", XMLfunctions.getValue(e, "meeting_name"));
                          map.put("hostname", XMLfunctions.getValue(e, "host_name"));
                          mylist.add(map);
  
  
  
              }       
  
              ListAdapter adapter = new SimpleAdapter(MeetingManager.this, mylist , R.layout.listlayout, 
                              new String[] {"time","endtime", "name", "hostname" }, 
                              new int[] { R.id.time, R.id.endtime, R.id.meeting_name, R.id.host });
  
             setListAdapter(adapter);
  
      }
  </code></pre>
  
  <p>I do not get an error everytime in my logCat but I did see this come through on one of my test.</p>
  
  <pre><code>12-14 09:39:29.584: ERROR/AndroidRuntime(572): FATAL EXCEPTION: Timer-0
  12-14 09:39:29.584: ERROR/AndroidRuntime(572): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.view.ViewRoot.checkThread(ViewRoot.java:2802)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.view.ViewRoot.requestLayout(ViewRoot.java:594)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.view.View.requestLayout(View.java:8125)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.view.View.requestLayout(View.java:8125)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.view.View.requestLayout(View.java:8125)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.view.View.requestLayout(View.java:8125)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.widget.TextView.checkForRelayout(TextView.java:5378)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.widget.TextView.setText(TextView.java:2688)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.widget.TextView.setText(TextView.java:2556)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at android.widget.TextView.setText(TextView.java:2531)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at com.MeetingManager.MeetingManager.TimerMethod(MeetingManager.java:171)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at com.MeetingManager.MeetingManager$2.run(MeetingManager.java:68)
  12-14 09:39:29.584: ERROR/AndroidRuntime(572):     at java.util.Timer$TimerImpl.run(Timer.java:289)
  </code></pre>