title: Using onNewIntent and activity lifecycle to verify if a message has been seen
body: <p>I have a push notification server to deliver messages to my Android app and I'd like to know the best way to notify the server when the message has been seen. </p>
  
  <p>Currently i'm trying to send the ack message to the server as soon as the main activity of my app calls its onResume callback, but as I use a SingleTop main activity, and I treat some intents with the onNewIntent method, I cannot be sure if the onResume is due to an Intent or the app coming to the foreground. I've mapped the callback flow in the three situations my activity can be when it receives an intent to start it, and they are:</p>
  
  <ul>
  <li><p>The activity is running on the foreground (top of the stack)(1)</p>
  
  <p>Running -> onPause() -> onNewIntent(intent) -> onResume()</p></li>
  <li><p>The activity is paused on the foreground (screen of for example)(2)</p>
  
  <p>Paused -> onRestart() -> onStart() -> onResume() -> onPause() -> onNewIntent(intent)</p></li>
  <li><p>The activity is paused on the background (i'm in another activity, for example)(3)</p>
  
  <p>Paused on background -> onNewIntent(intent) -> onRestart() -> onStart() -> onResume()</p></li>
  </ul>
  
  <p>In the case i navigate to my activity without receiving an intent:</p>
  
  <ul>
  <li><p>The activity is paused and the user navigates to it (4)</p>
  
  <p>Paused -> onRestart() -> onStart() -> onResume()</p></li>
  </ul>
  
  <p>In cases 1, 3 and 4 the user ends in a screen where he/she can actually see the message, so i want to send the ack message.</p>
  
  <p>If there was a callback that is called just in the case the activity really become visible in the screen it'd be perfect, but I'm having trouble finding it. </p>
  
  <p>Someone know how can I solve this?</p>