سؤال

I'm testing my app on Android 4.4.2. My app is the default sms app.

I use this code to write an sms:

ContentValues values = new ContentValues();
values.put("address", phoneNumber);
values.put("date", System.currentTimeMillis());
values.put("body", message);
values.put("type", inbox);
values.put("read", read);
context.getContentResolver().insert(Uri.parse("content://sms"), values);

The message was write correctly but its date is setting on 1/01/1970.

On Android 4.0.x, 4.1.x and 4.2.x this save the data correctly, but on android 4.4.2 no.

The problem is the System.currentTimeMillis()? How can i solve this?

Edit: The problem interesting only the original timestamp. The received timestamp remain set on 01/01/1970. Maybe i must add another paramether to save this other information?

Thank you.

هل كانت مفيدة؟

المحلول

You have to use date_sent not date:

values.put("date_sent", System.currentTimeMillis());

Otherwise, date_sent will be 0 which corresponds to 01/01/1970!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top