How does android calculate the value for last time contacted. It provides the value in integer format but I am unable to decipher the given value. For example what if I want to compare the two give values to know which contact has been contacted later. Any type of help would be appreciated.
-
Please note that the constant LAST_TIME_CONTACTED has been deprecated in October 2018, along with TIMES_CONTACTED. See the [reference](https://developer.android.com/reference/android/provider/ContactsContract.ContactOptionsColumns#LAST_TIME_CONTACTED) and [guide](https://developer.android.com/guide/topics/providers/contacts-provider#ObsoleteData) – HendrikFrans Oct 15 '18 at 13:02
2 Answers
The value you receive is returned in long format and holds the date and time information of the last time called has happened from a particular number.
It returns the milliseconds of that number.
For your reference: http://developer.android.com/reference/android/provider/ContactsContract.ContactOptionsColumns.html#LAST_TIME_CONTACTED
Now how to compute date and time here is the link: how to convert milliseconds to date format in android?
How to compare: There are functions "before" and "after" which tells whether the event date is before or after another specified date
Date class: http://developer.android.com/reference/java/util/Date.html#after(java.util.Date)
or
Calendar class: http://developer.android.com/reference/java/util/Calendar.html#after(java.lang.Object)
Depends which one you want to use.
I hope it helps and let me know for more info.
-
1Thanks for replying. But I already know what you have posted. So here is my problem. I get a positive value for those who I contacted just a day ago. Next I get a negative value for those who were contacted about 1-2 months ago. Lastly I get a positive value for those who were contacted more than 4-5 months ago and this value is very near to the value returned by last time contacted for recently called contacts(who were contacted just a day ago). This is freaking me out. I am using Sony Ericsson E16i for fetching all these values. Is my device erroneous or is it supposed to work this way. – aps109 Jul 04 '12 at 17:13
-
Maybe some problem with Sony mobiles but I never faced this issue about values getting negative. Thanks for letting me know about the issue in detail, so I'll be careful if I ever use LastTimeContacted any time. – abhy Jul 05 '12 at 12:54
Every time you contact someone, (i.e. make the call Contacts.markAsContacted) the TIMES_CONTACTED should increment by 1 and LAST_TIME_CONTACTED should be updated. However, many device manufacturers have changed this functionality and it is not reliable anymore. There is an open bug for this issue which you could find at

- 9,989
- 23
- 68
- 112
-
Last time contacted holds true for calls only but your link made me to think that when we are sending SMS or Email we are ultimately contacting with that particular contact. Thanks for sharing. But anyways it will never fail when someone tries to contact via Call. – abhy Jul 03 '12 at 15:55
-
@Suchi what is considered a "contact"? Is it just a phone call or will a text message also increment the counter? – MobileMon Nov 11 '13 at 17:06