我试图从通话记录中提取Android的通话记录中的信息 。我从 的实际通话时间起收到一个月的通话日期。我的意思是说,由我拨打提取的电话号码的信息比实际电话号码 日期晚了一个月。无法获得通话记录历史记录的正确月份
我在模拟器中有以下内容:
我保存了一个联系人。然后我打电话给联系人。
代码:
我有提取通话日期信息,但得到同样的 错误的结果的3种方式。我的代码如下:
/* Make the query to call log content */
Cursor callLogResult = context.getContentResolver().query(
CallLog.Calls.CONTENT_URI, null, null, null, null);
int columnIndex = callLogResult.getColumnIndex(Calls.DATE);
Long timeInResult = callLogResult.getLong(columnIndex);
/* Method 1 to change the milliseconds obtained to the readable date formate */
Time time = new Time();
time.toMillis(true);
time.set(timeInResult);
String callDate= time.monthDay+"-"+time.month+"-"+time.year;
/* Method 2 for extracting the date from tha value read from the column */
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
String Month = calendar.get(Calendar.MONTH) ;
/* Method 3 for extracting date from the result obtained */
Date date = new Date(timeInResult);
String mont = date.getMonth()
在使用日历的方法,我也试图设置日光 节省偏移,但它因此未工作,
calendar.setTimeZone(TimeZone.getTimeZone("Europe/Paris"));
int DST_OFFSET = calendar.get( Calendar.DST_OFFSET); // DST_OFFSET
Boolean isSet = calendar.getTimeZone().useDaylightTime();
if(isSet)
calendar.set(Calendar.DST_OFFSET , 0);
int reCheck = calendar.get(Calendar.DST_OFFSET);
但值不为0复检。我也通过使用这个月得到错误的 月价值。
请有人帮我,我错了吗?或者这是 模拟器中的错误?
感谢, NISHANT库马尔 工程学生