Android sms 发送、接收及格式
2010-03-09 15:44:00 来源:WEB开发网Uri smsInBox = Uri.parse(SMS_URI_INBOX);
Cursor c = ctx.getContentResolver().query(uriSms, null, selection, selectionArgs, sortOrder);
//对字段进行操作。。。
//ctx.getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder);
//ctx.getContentResolver().update(uri, values, where, selectionArgs);
//ctx.getContentResolver().delete(url, where, selectionArgs);
//ctx.getContentResolver().insert(url, values);
public void onChange(boolean selfChange)
Uri smsInBox = Uri.parse(SMS_URI_INBOX);
Cursor c = ctx.getContentResolver().query(uriSms, null, selection, selectionArgs, sortOrder);
//对字段进行操作。。。
//ctx.getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder);
//ctx.getContentResolver().update(uri, values, where, selectionArgs);
//ctx.getContentResolver().delete(url, where, selectionArgs);
//ctx.getContentResolver().insert(url, values);
b. 在Activity中注册短信监控
Java代码
// 监控短信
smsObserver = new SMSDBObserver(new Handler(), this, app);
getContentResolver().registerContentObserver(Uri.parse(SMSDBObserver.SMS_URI_ALL), true, smsObserver);
// 监控短信
smsObserver = new SMSDBObserver(new Handler(), this, app);
getContentResolver().registerContentObserver(Uri.parse(SMSDBObserver.SMS_URI_ALL), true, smsObserver);
注:
想监控已发送的,就要监控content://sms/send.
想删除时contentUri只能是content://sms/或content://sms/ conversations
更多精彩
赞助商链接