pakuti
pakuti

Reputation: 57

mms sent/recive date is always in 1970

from below code i am able to get the MMS but the date is always wrong. might be i am doing something wrong while conversion.

   Cursor cursor = activity.getContentResolver().query(Uri.parse("content://mms"),null,null,null,date DESC);
count = cursor.getCount();
if (count > 0) {
  cursor.moveToFirst();
    long messageId = cursor.getLong(0);
   long timestamp = cursor.getLong(2);
   Date date = new Date(timestamp);
   String subject = cursor.getString(3);

}

Upvotes: 2

Views: 2060

Answers (2)

Ajay Singh
Ajay Singh

Reputation: 1621

just some change.

long timestamp = cursor.getLong(2) * 1000;

Upvotes: 10

Jana
Jana

Reputation: 2920

Check you device or emulator's date.. when ever you reset your phone the date sets back to 1970.

you can enable the Automatic(network provided values) in date ant time settings to avoid this issue.

Upvotes: 0

Related Questions