Android短信开发相关信息记录

相关的协议:

content://sms/inbox        收件箱

content://sms/sent        已发送

content://sms/draft        草稿

content://sms/outbox        发件箱

content://sms/failed        发送失败

content://sms/queued        待发送列表


sms相关的字段如下:

_id               一个自增字段,从1开始
thread_id    序号,同一发信人的id相同
address      发件人手机号码
person        联系人列表里的序号,陌生人为null
date            发件日期
protocol      协议,分为: 0 SMS_RPOTO, 1 MMS_PROTO 
read           是否阅读 0未读, 1已读 
status         状态 -1接收,0 complete, 64 pending, 128 failed
type
    ALL    = 0;
    INBOX  = 1;
    SENT   = 2;
    DRAFT  = 3;
    OUTBOX = 4;
    FAILED = 5;
    QUEUED = 6;

body                     短信内容
service_center     短信服务中心号码编号
subject                  短信的主题
reply_path_present     TP-Reply-Path 

删除短信:

getContentResolver().delete(Uri.parse("content://sms"), "_id=?", new String[]{"3"}); 

getContentResolver().delete(Uri.parse("content://sms/conversations/3"), "_id=?", new String[]{"5"});  

修改短信:

ContentValues cv = new ContentValues();   
cv.put("thread_id", "2");   
cv.put("address", "00000");   
cv.put("person", "11");   
cv.put("date", "11111111");   
this.getContentResolver().update(Uri.parse("content://sms/inbox/4"), cv, null, null);    


插入短信:

ContentValues cv = new ContentValues();   
cv.put("_id", "99");   
cv.put("thread_id", "0");   
cv.put("address", "9999");   
cv.put("person", "888");   
cv.put("date", "9999");
cv.put("protocol", "0");
cv.put("read", "1");
cv.put("status", "-1");
//cv.put("type", "0");
cv.put("body", "@@@@@@@@@");
this.getContentResolver().insert(Uri.parse("content://sms/failed"), cv); 



  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这是一个自己开发Android 直接发送方法附上代码,Android功能,包括了对内容合法性的验证,发送完成弹出提示。自己开发的直接发送的方法:   private void sendSMS(String telNo,String smsStr,View v){    PendingIntent pi=    PendingIntent.getActivity(this, 0, new Intent(this,Sample_11_1.class), 0);    SmsManager sms=SmsManager.getDefault();    sms.sendTextMessage(telNo, null, smsStr, pi, null);    //发送成功给予提示    Toast.makeText(    Sample_11_1.this, //上下文    "恭喜你,发送成功!", //提示内容    5000 //信息显示时间    ).show();    v.setEnabled(true);//发送完成后恢复发送按钮的可用状态   }   对手机号码和内容的验证部分:   //获取输入的电话号码   EditText etTel=(EditText)findViewById(R.id.EditText02);   String telStr=etTel.getText().toString();   //获取输入的内容   EditText etSms=(EditText)findViewById(R.id.EditText01);   String smsStr=etSms.getText().toString();   //判断号码字符串是否合法   if(PhoneNumberUtils.isGlobalPhoneNumber(telStr)){//合法则发送    v.setEnabled(false);//发送完成前将发送按钮设置为不可用    sendSMS(telStr,smsStr,v);   }   else{//不合法则提示    Toast.makeText(    Sample_11_1.this, //上下文    "电话号码不符合格式!!!", //提示内容    5000//信息显示时间    ).show();   }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值