Android开发之短信
2014-09-25 22:19
162 查看
1. sms主要结构:
_id:短信序号,如100
thread_id:对话的序号,如100,与同一个手机号互发的短信,其序号是相同的
address:发件人地址,即手机号,如+86138138000
person:发件人,如果发件人在通讯录中则为具体姓名,陌生人为null
date:日期,long型,如1346988516,可以对日期显示格式进行设置
protocol:协议0SMS_RPOTO短信,1MMS_PROTO彩信
read:是否阅读0未读,1已读
status:短信状态-1接收,0complete,64pending,128failed
type:短信类型1是接收到的,2是已发出
body:短信具体内容
service_center:短信服务中心号码编号,如+8613800755500
2.短信的Uri存放位置
String SMS_URI_ALL="content://sms/";
String SMS_URI_INBOX="content://sms/inbox";
String SMS_URI_SENT="content://sms/sent";
String SMS_URI_DRAFT="content://sms/draft";
String SMS_URI_OUTBOX="content://sms/outbox";
String SMS_URI_FAILED="content://sms/failed";
String SMS_URI_QUEUED="content://sms/queued";
3. 实例
1)添加权限
2)
_id:短信序号,如100
thread_id:对话的序号,如100,与同一个手机号互发的短信,其序号是相同的
address:发件人地址,即手机号,如+86138138000
person:发件人,如果发件人在通讯录中则为具体姓名,陌生人为null
date:日期,long型,如1346988516,可以对日期显示格式进行设置
protocol:协议0SMS_RPOTO短信,1MMS_PROTO彩信
read:是否阅读0未读,1已读
status:短信状态-1接收,0complete,64pending,128failed
type:短信类型1是接收到的,2是已发出
body:短信具体内容
service_center:短信服务中心号码编号,如+8613800755500
2.短信的Uri存放位置
String SMS_URI_ALL="content://sms/";
String SMS_URI_INBOX="content://sms/inbox";
String SMS_URI_SENT="content://sms/sent";
String SMS_URI_DRAFT="content://sms/draft";
String SMS_URI_OUTBOX="content://sms/outbox";
String SMS_URI_FAILED="content://sms/failed";
String SMS_URI_QUEUED="content://sms/queued";
3. 实例
1)添加权限
2)
private Uri SMS_inBox=Uri.parse("content://sms/"); public void getSMS() { ContentResolver cr=getContentResolver(); Cursor cursor=cr.query(SMS_inBox, null, null, null, null); String msg=""; while(cursor.moveToNext()) { String number=cursor.getString(cursor.getColumnIndex("address")); String name=cursor.getString(cursor.getColumnIndex("person")); String date=cursor.getString(cursor.getColumnIndex("date")); String _id=cursor.getString(cursor.getColumnIndex("_id")); String thread_id=cursor.getString(cursor.getColumnIndex("thread_id")); String protocol=cursor.getString(cursor.getColumnIndex("protocol")); String read=cursor.getString(cursor.getColumnIndex("read")); String status=cursor.getString(cursor.getColumnIndex("status")); String type=cursor.getString(cursor.getColumnIndex("type")); String service_center=cursor.getString(cursor.getColumnIndex("service_center")); String body=cursor.getString(cursor.getColumnIndex("body")); msg+= "短信序号:"+_id+"\n"+ "对话序号:"+thread_id+"\n"+ "号码"+number+"\n"+ "联系人:"+name+"\n"+ "日期:"+date+"\n"+ "协议:"+protocol+"\n"+ "是否阅读:"+read+"\n"+ "状态:"+status+"\n"+ "类型:"+type+"\n"+ "短信中心:"+service_center+"\n"+ "内容:"+body+'\n'; } tx.setText(msg); }
相关文章推荐
- Android 开发之旅:短信的收发及在android模拟器之间实践(一)
- Android 开发之旅:短信的收发及在android模拟器之间实践(二)
- Android软件开发之发送短信与系统短信库解析(三十)
- Android UI开发第四篇——实现像handcent sms或者chomp sms那样的气泡短信样式
- Android UI开发第四篇——实现像handcent sms或者chomp sms那样的气泡短信样式
- Android开发(一)发送短信程序
- android开发之短信窃听器
- Android短信彩信开发手记(一):数据库相关
- android开发之Widget AppWidgetProvider 桌面短信
- android 添加菜单 开发流程 短信发送与拨打电话
- Android 开发之旅:短信的收发及在android模拟器之间实践(二)
- Android简明开发教程二十:Broadcast Receiver 短信触发示例
- Android开发中遇到读取数据库中的短信问题
- Android开发之短信发送
- Android 开发之旅:短信的收发及在android模拟器之间实践(一)
- Android 开发之旅:短信的收发及在android模拟器之间实践(一)
- Android 开发之旅:短信的收发及在android模拟器之间实践(二)
- Android简明开发教程二十:Broadcast Receiver 短信触发示例
- Android 开发之旅:短信的收发及在android模拟器之间实践(二)
- Android短信彩信开发手记(一):数据库相关