android – 如何访问我在收件箱中收到的短信时间?

android – 如何访问我在收件箱中收到的短信时间?,第1张

概述我可以从收件箱中读取消息: – Uri uriSMSURI = Uri.parse("content://sms/inbox"); Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null); 我从这里访问日期: – date = cur.getString(cur.getColumnIndexOrThr 我可以从收件箱中读取消息: –
Uri uriSMSURI = Uri.parse("content://sms/inBox"); Cursor cur = getContentResolver().query(uriSMSURI,null,null);

我从这里访问日期: –

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

但现在问题是它从收件箱中提供当前时间而不是消息时间.
对不起编辑错误&任何想法将不胜感激.
提前致谢!

解决方法 使用此代码:
ContentResolver contentResolver = getContentResolver();Cursor cursor = contentResolver.query( Uri.parse( "content://sms/inBox" ),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);
总结

以上是内存溢出为你收集整理的android – 如何访问我在收件箱中收到短信时间?全部内容,希望文章能够帮你解决android – 如何访问我在收件箱中收到的短信时间?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1137771.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存