当我使用Cursor使用Cursor获取调用持续时间时,它返回总时间。要获得今天的通话时间,我只会尝试:
public long getTodayTimestamp(){
Calendar c1=Calendar.getInstance();
c1.setTime(new Date());
Calendar c2=Calendar.getInstance();
c2.set(Calendar.YEAR, c1.get(Calendar.YEAR));
c2.set(Calendar.MONTH, c1.get(Calendar.MONTH));
c2.set(Calendar.DAY_OF_MONTH, c1.get(Calendar.DAY_OF_MONTH));
c2.set(Calendar.HOUR_OF_DAY, 0);
c2.set(Calendar.MINUTE, 0);
c2.set(Calendar.SECOND, 0);
return c2.getTimeInMillis();
}
然后这样做:
String timestap=String.valueOf(getTodayTimestamp());
Cursor managedCursor =managedQuery(CallLog.Calls.CONTENT_URI, null,
null, null, android.provider.CallLog.Calls.DATE + " DESC");
......
哪个仍然不起作用。如何仅为今天的calllog条目返回时间戳。