如何查看我在收件箱中收到的短信时间?

2024-06-26

我可以从收件箱中读取消息:--

 Uri uriSMSURI = Uri.parse("content://sms/inbox");

 Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null);

我从此访问日期:-

   date = cur.getString(cur.getColumnIndexOrThrow("date"));

但现在的问题是它给出的是当前时间而不是收件箱中的消息时间。 抱歉编辑不好,任何想法将不胜感激。 提前致谢!


使用此代码:

ContentResolver contentResolver = getContentResolver();
Cursor cursor = contentResolver.query( Uri.parse( "content://sms/inbox" ), null, null, null, null);
cursor.moveToFirst();
String date =  cursor.getString(cursor.getColumnIndex("date"));
Long timestamp = Long.parseLong(date);    
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(timestamp);
Date finaldate = calendar.getTime();
String smsDate = finaldate.toString();
Log.d(Home.class.getName(), smsDate);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何查看我在收件箱中收到的短信时间? 的相关文章

随机推荐