我在查询CallLog.Calls
内容提供商的详细呼叫。我做这种事按当前日期查询CallLog.Calls
Cursor managedCursor = cr.query(CallLog.Calls.CONTENT_URI, null,
null, null, null);
通过这种方式,我得到所有的通话记录。但现在我想通过当前日期进行查询,以便只获取当前日期calllogs。应该如何解决这个问题?
我在查询CallLog.Calls
内容提供商的详细呼叫。我做这种事按当前日期查询CallLog.Calls
Cursor managedCursor = cr.query(CallLog.Calls.CONTENT_URI, null,
null, null, null);
通过这种方式,我得到所有的通话记录。但现在我想通过当前日期进行查询,以便只获取当前日期calllogs。应该如何解决这个问题?
试试这个:
//With this method you will get the timestamp of today at midnight
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 = cr.query(CallLog.Calls.CONTENT_URI, CallLog.Calls.DATE + ">= ?", new String[]{timestamp}, null);
我相信这已经回答了[这里](http://stackoverflow.com/questions/5516423/calllog-calls-query-by-date) – Andrei