Ich lese SMS und MMS Daten von meinem Galaxy S6. Alle SMS Nachrichten haben ein date
Feld wie dieses 1456252633000
. Die Nummer ist der Unix-Zeitstempel * 1000. Die MMS-Nachrichten, die ich sendete (nicht erhalten), haben Datumsfelder wie diese: 1440628863
Der Zeitstempel ist im Unix-Zeitformat korrekt. Die MMS-Nachrichten, die ich empfange, haben Zeitstempel vollständig wie folgt: 1454881665
.MMS Datum ist immer falsch
Die beiden letzten Zeitstempel oben sind aufeinanderfolgend, aber der zweite zeigt, als wäre es Monate zuvor. Warum ist das so? Gibt es etwas, was ich hier falsch mache?
EDIT
Ich las diesen (How do the retrieve the date of the mms from content://mms.) und stellt sich heraus, dass mein Problem ähnlich ist. Das Datum wird im Jahr 1970 steckt Aber auch, nachdem es in Millisekunden Umwandlung (1440185636 * 1000
) Ich bekomme immer noch das falsche Datum ...
EDIT 2
Ich versuche, mit den Werten wie Long-Positionen zu konvertieren, Das Datum wird jedoch immer noch als Monate angezeigt.
Als Referenz war es 2/9/2016. Ich bekomme 26.08.2015, wenn ich die Konvertierung mache. Der Referenzzeitstempel lautet: 1440603051L * 1000L
.
EDIT 3
Hier ist ein Code:
ContentResolver contentResolver = context.getContentResolver();
Cursor c = contentResolver.query(Telephony.Mms.CONTENT_URI, null, filter, null, null);
JSONArray array = new JSONArray();
try {
if (c.moveToFirst()) {
do {
try {
String[] cols = c.getColumnNames();
String id = c.getString(c.getColumnIndexOrThrow("_id"));
JSONObject msg = populateFromMmsPart(id);
if (msg != null) {
msg.put("id", id);
msg.put("read", c.getString(c.getColumnIndexOrThrow("read")).contains("1"));
msg.put("time", c.getString(c.getColumnIndexOrThrow("date")));
msg.put("m_id", c.getString(c.getColumnIndexOrThrow("m_id")));
msg.put("received", c.getString(c.getColumnIndexOrThrow("msg_box")).contains("1"));
msg.put("thread_id", c.getString(c.getColumnIndexOrThrow("thread_id")));
array.put(msg);
}
} catch (JSONException j) {
j.printStackTrace();
}
} while (c.moveToNext());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
c.close();
}
private JSONObject populateFromMmsPart(String msgId) {
ContentResolver contentResolver = context.getContentResolver();
Uri messages = Uri.parse("content://mms/part");
Cursor c = contentResolver.query(messages, null, "_id=" + msgId, null, null);
JSONObject msg = null;
if (c.moveToFirst()) {
try {
String mid = c.getString(c.getColumnIndex("mid"));
String type = c.getString(c.getColumnIndex("ct"));
if (!"application/smil".equals(type)) {
// Put all the addresses in one place
msg = new JSONObject();
msg.put("address", getAddressesForMmsMessages(mid));
msg.put("mid", mid);
msg.put("type", type);
if ("text/plain".equals(type)) {
// MMS is just plain text, so get the text
String data = c.getString(c.getColumnIndex("_data"));
String body;
if (data != null) {
body = getMmsText(msgId);
} else {
body = c.getString(c.getColumnIndex("text"));
}
msg.put("msg", body);
}
}
} catch (JSONException j) {
j.printStackTrace();
}
}
c.close();
return msg;
}
Früher war ich tun:
ContentResolver contentResolver = context.getContentResolver();
final String[] projection = new String[]{"*"};
Uri uri = Uri.parse("content://mms-sms/conversations/");
Cursor query = contentResolver.query(uri, projection, "thread_id=109", null, null);
Und ich war die unten stehende Störung zu erhalten:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
Wird Ihr Zeitstempel als Float gespeichert? – bdavies6086
Dont denke ich nicht, ich denke es ist ein Long. – KVISH