org.jivesoftware.smackx.iqlast.LastActivityManager Java Examples
The following examples show how to use
org.jivesoftware.smackx.iqlast.LastActivityManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMPPManager.java From Yahala-Messenger with MIT License | 5 votes |
public String getLastSeenMessage(String jid) { if (!isConnected() || !connection.isAuthenticated()) { return LocaleController.getString("Offline", R.string.Offline); } try { LastActivityManager lastActivityManager = LastActivityManager.getInstanceFor(connection); LastActivity activity = lastActivityManager.getLastActivity(JidCreate.bareFrom(jid)); int lastSeenBySeconds = Utilities.parseInt(activity.lastActivity + ""); String lastSeenMessage = ""; lastSeenMessage = LocaleController.getString("Offline", R.string.Offline); if (lastSeenBySeconds >= 1) { PrettyTime p = new PrettyTime(); Date date = new Date(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.SECOND, -1 * lastSeenBySeconds); lastSeenMessage = LocaleController.formatDateOnline(cal.getTime()); //p.format(cal.getTime()); } else { lastSeenMessage = LocaleController.getString("Offline", R.string.Offline); } //FileLog.e("LAST ACTIVITY","" + ""+ "" + lastSeenBySeconds +" "+jid); return lastSeenMessage; } catch (Exception e) { e.printStackTrace(); return LocaleController.getString("Offline", R.string.Offline); } //return "Offline"; }