title: Keep updating Android UI from service, when activity is closed / restarted
body: <p>Trying to figure this out for a while. I have got an app that runs a countdown in a separate <code>service</code> which calls <code>startsForeground</code>, displaying a notification. I start the countdown service from a button:</p>
  
  <pre><code>            Intent i = new Intent(getApplicationContext(),  PomoService.class);
              i.putExtra("EXTRA_MESSENGER", new Messenger(handler));
              startService(i);
  </code></pre>
  
  <p>and I update the UI with an <code>handler</code>, which received the bundle data telling how many milliseconds are left in the countdown, sent via message in the <code>onTick()</code> method:</p>
  
  <pre><code>Messenger messenger = (Messenger)extras.get("EXTRA_MESSENGER");
          Message msg = new Message();
          Bundle b = new Bundle();
          b.putLong("remainingTime", millisUntilFinished);
          msg.setData(b);
          try {
              messenger.send(msg);
          } catch (RemoteException e) {
              Log.i("error", "error");
          }
  </code></pre>
  
  <p>And in the activity:</p>
  
  <pre><code>    private Handler handler = new Handler() {
      @Override
      public void handleMessage(Message msg) {
          long sentTime = msg.getData().getLong("remainingTime");
          textCountdownMin.setText(String.format("%02d", (sentTime/1000)/60));
          textCountdownSec.setText(":" + String.format("%02d", (sentTime/1000)%60));
      }
  };
  </code></pre>
  
  <p>The whole setup works fine, the only problem is that if the user hits the back button or swipes away the app from the recent app list and then reopens it either from the drawer or the ongoing notification, the text is not being updated any more. The countdown is still ongoing though, as I can see it both from the notification being still displayed and from the fact that I use an AlarmManager to wake the screen, and that's fired up correctly.</p>
  
  <p>Any clue on what measures I should take?</p>