0
我確實收到了關於如何檢索從此鏈接發送的mms文本和圖像的信息:How to Read MMS Data in Android?。如何從content:// mms中檢索mms的日期。
但我不知道如何檢索發送的mms的日期。
我知道我必須看看content:// mms而不是content:// mms/part。
這是評判檢索彩信的文字:
private String getMmsText(String id) {
Uri partURI = Uri.parse("content://mms/part/" + id);
InputStream is = null;
StringBuilder sb = new StringBuilder();
try {
is = getContentResolver().openInputStream(partURI);
if (is != null) {
InputStreamReader isr = new InputStreamReader(is, "UTF-8");
BufferedReader reader = new BufferedReader(isr);
String temp = reader.readLine();
while (temp != null) {
sb.append(temp);
temp = reader.readLine();
}
}
} catch (IOException e) {
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
}
}
}
return sb.toString();
}
,然後在onCreate方法,我用這個代碼來獲取信息:
Cursor cursor = getContentResolver().query(uri, null, selectionPart,
null, null);
if (cursor.moveToFirst()) {
do {
String partId = cursor.getString(cursor.getColumnIndex("_id"));
String type = cursor.getString(cursor.getColumnIndex("ct"));
if ("text/plain".equals(type)) {
String data = cursor.getString(cursor
.getColumnIndex("_data"));
if (data != null) {
// implementation of this method above
body = getMmsText(partId);
} else {
body = cursor.getString(cursor.getColumnIndex("text"));
}
}
} while (cursor.moveToNext());
}
try {
main.setText(body);
img.setImageBitmap(bitmap);
} catch (Exception e) {
e.printStackTrace();
}
我只是想知道我可以在哪裏進行更改以獲取日期值。
有些信息會非常有幫助。
感謝信息。這真的很有幫助.. :)。該代碼正在工作,但由於某種原因,該年顯示爲1970年。 – mike20132013
啊。查看我的編輯:)只需更改爲:long timestamp =(cursor.getLong(2)* 1000); - 應該整理:) – LokiSinclair
perfect..its working .. :) – mike20132013