How to get last seen using asmack 4.0.5 in android

I am using asmack 4.0.5 and want to retreive last seen of a users .I tried using

LastActivityManager lActivityManager = LastActivityManager`` .getInstanceFor(mConnection);

try { 
Log.v(TAG, "Last Activity: " + lActivityManager.getLastActivity(pArg0.getFrom()));
} catch (NoResponseException e)
 {  e.printStackTrace(); }
catch (XMPPErrorException e)
 {  e.printStackTrace(); }
 catch (NotConnectedException e)
{  e.printStackTrace(); }

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.