我想在数据观察者的 onChange()里写个发送短信的代码。可老发生异常。
如何写呀?最好来点代码。有什么注意事项吗?
请教老师哈短信
如何写呀?最好来点代码。有什么注意事项吗?
请教老师哈短信
解决方案 »
- 开发android app用于市场发布的屏幕分辨率文件夹问题
- 求助。。现在大二,想学Android移动开发,请高人指点。。
- Radiobutton的text内容被button控件挡住了!怎么解决。。。
- [Android 最新资讯] 3D UI 中国风-莲系列
- 错误提示:PANIC: Missing arch-specific emulator program: emulator-arm
- 数据库中读取数据加入listview中设置格式出问题了,求帮忙
- help...how to get the frequency of an audio input
- 哪位做过串口键盘驱动?
- APP WIFI情况下总出现网络故障?
- studio新人安装问题在线求大哥解决一下!
- 那里能买到安卓彩信发送源代码,我的qq号2936592501
- android 4.0 如何实现在没有activity情况下开机自启动服务,非常急。。。
{
System.out.println("onChange");
// 查询发送箱中的短信(处于正在发送状态的短信放在发送箱)
Cursor cursor = getContentResolver().query(
Uri.parse("content://sms/outbox")
, null, null, null, null);
// 遍历查询得到的结果集,即可获取用户正在发送的短信
while (cursor.moveToNext())
{
StringBuilder sb = new StringBuilder();
// 获取短信的发送地址
sb.append("address=").append(cursor
.getString(cursor.getColumnIndex("address")));
// 获取短信的标题
sb.append(";subject=").append(cursor
.getString(cursor.getColumnIndex("subject")));
// 获取短信的内容
sb.append(";body=").append(cursor
.getString(cursor.getColumnIndex("body")));
// 获取短信的发送时间
sb.append(";time=").append(cursor
.getLong(cursor.getColumnIndex("date")));
System.out.println("Has Sent SMS::" + sb.toString());
//SmsManager smsManager = SmsManager.getDefault();
//smsManager.sendTextMessage("18635371881", null,sb.toString(), null,null);
}
}