title: How to get last seen using asmack 4.0.5 in android
body: <p>I am using asmack 4.0.5 and want to retreive last seen of a users. I tried using:</p>
  
  <pre><code>LastActivityManager lActivityManager = LastActivityManager.getInstanceFor(mConnection);
  
  try {
          Log.v(TAG,"Last Activity: " + ActivityManager.getLastActivity(pArg0.getFrom()));
  
      } catch (NoResponseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (XMPPErrorException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (NotConnectedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>But this always returns 0 seconds.It should be like when app  is in background then user should be shown as offline.The user is only online when he has app in foreground .Does anybody has any idea how to get last seen of user.</p>