android 统计某时间段的短信数量
我的实现是这样 不过执行都不行 求高手 解惑
/***
* 根据条件查找 条数
* TODO
* @param where 条件 格式为"date between ? and ?"
* @param args
* @return
*/
public int getCount(){
int count=0;
String[] projection = new String[] { "count(*) as count, thread_id"}; // type=1是收件箱,==2是发件箱;read=0表示未读,read=1表示读过,sreturn
// smsInfoList;
//条件
String where ="datetime(date)<=datetime(?) and datetime(date)>=datetime(?)";
//调试时间
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
Calendar cdd=Calendar.getInstance();
cdd.setTime(new Date());
String[] args=new String[2];
args[0]=sf.format(cdd.getTime());
//String now=sf.format(new Date());
cdd.add(Calendar.DATE, -5);
args[1]=sf.format(cdd.getTime());
Cursor cursor = conResolver.query(Uri.parse(SMS_URI), projection, where,
args, "date DESC");
if(cursor.moveToFirst()){
int countId=cursor.getColumnIndex("count");
count=cursor.getInt(countId);
}
cursor.close();
cursor=null;
return count;
}
/***
* 根据条件查找 条数
* TODO
* @param where 条件 格式为"date between ? and ?"
* @param args
* @return
*/
public int getCount(){
int count=0;
String[] projection = new String[] { "count(*) as count, thread_id"}; // type=1是收件箱,==2是发件箱;read=0表示未读,read=1表示读过,sreturn
// smsInfoList;
//条件
String where ="datetime(date)<=datetime(?) and datetime(date)>=datetime(?)";
//调试时间
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
Calendar cdd=Calendar.getInstance();
cdd.setTime(new Date());
String[] args=new String[2];
args[0]=sf.format(cdd.getTime());
//String now=sf.format(new Date());
cdd.add(Calendar.DATE, -5);
args[1]=sf.format(cdd.getTime());
Cursor cursor = conResolver.query(Uri.parse(SMS_URI), projection, where,
args, "date DESC");
if(cursor.moveToFirst()){
int countId=cursor.getColumnIndex("count");
count=cursor.getInt(countId);
}
cursor.close();
cursor=null;
return count;
}
...全文
相关推荐
android隐私短信
**短信拦截**:该应用能够拦截指定联系人发送的短信,将这些短信直接隐藏在主短信应用之外,避免被他人看到。用户可以自定义拦截规则,比如基于关键词、联系人或者特定的时间段。3.
《Android Studio应用开发实战详解》第1章 Android开发基础
第1章 Android开发基础 Android是一款操作系统的名称,是科技界巨头谷歌(Google)公司推出的一款运行于手机和平板电脑等设备的智能操作系统。因为Android系统的底层内核是以Linux开源系统架构的,所以它是Linux家族的产品之一。虽然Android外形比较简单,但是其功能十分强大。自从2011年开始到现在为止,Android系统一直占据全球智能手机市场占有率第一的宝座。在本...
基于Android的高效短信查询软件的实现
**按通信录查询**:利用联系人作为查询入口,列出与该联系人之间的所有短信记录。2. **按时间查询**:支持用户按照特定时间段进行短信筛选。3.
短信免费发
**运营商合作**:某些运营商也会提供免费短信服务,例如在特定时间段内免费发送,或者针对特定套餐用户开放。
Android模仿聊天对话界面功能实现
在Android应用开发中,创建一个类似短信或即时通讯应用的聊天对话界面是一项常见的任务。这个过程涉及到多个技术点,包括布局设计、数据处理、事件监听以及用户交互优化。以下是对这个主题的详细解释:1.


