title: Updating UI from a service (using a handler?)
body: <p>I am trying to update my UI in <code>FirstActivity</code> when I receive a notification but is confused by <code>runOnUiThread</code> , <code>Runnable</code> and <code>Handler</code>. Here is what I have: I am running FirstActivity and NotificationService. When NotificationService reeives a notification, it will update FirstActivity UI.</p>
  
  <p>I also have another service <code>AlarmService</code> running.
  First Activity</p>
  
  <pre><code>@Override
  public void onResume() {
        super.onResume();
        //some other code for alarm service
  }
  </code></pre>
  
  <p>NotificationService </p>
  
  <pre><code>    //on receiving notification
      private void showNotification(String text) {
  
     //Get activity
     Class&lt;?&gt; activityClass = null;
       try {
           activityClass = Class.forName("com.pakage.FirstActivity");
           contextActivity = (Activity) activityClass.newInstance();
  
           //Update UI on FirstActivity not working
           contextActivity.runOnUiThread(new Runnable() {
               public void run()
               { 
                 Looper.prepare();
                 TextView tv = (TextView ) contextActivity.findViewById(R.id.notifyTest);
                 Looper.loop();
  
               }
               });
  
       } catch (Exception e) {
           e.printStackTrace();
       }
  
              //Shows the notification
              Notification n = new Notification();    
              //... etc   
  }
  </code></pre>
  
  <p>I keep getting looper.prepare error. Do I need to put extra codes in my FirstActivity?</p>