我試圖從通話記錄中提取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庫馬爾 工程學生