我可以从收件箱中读取消息: –
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);