zoukankan      html  css  js  c++  java
  • 访问短信和写假短信

    访问短信代码(bean类是Sms):

    public List<Sms> readSMS(Context context) {
            List smsList = new ArrayList<Sms>();
            ContentResolver resolber = context.getContentResolver();
            Cursor cursor = resolber.query(Uri.parse("content://sms/"), null, null, null, null);
            if (cursor != null && cursor.getCount() > 0) {
                while (cursor.moveToNext()) {
                    String address = cursor.getString(cursor.getColumnIndex("address"));
                    String type = cursor.getString(cursor.getColumnIndex("type"));
                    long date = cursor.getLong(cursor.getColumnIndex("date"));
                    String body = cursor.getString(cursor.getColumnIndex("body"));
                    String str = "";
                    if (type.equals("1")) {
                        str = "发送";
                    } else {
                        str = "接收";
                    }
                    smsList.add(new Sms(str, address, date, body));
                    Log.d(TAG, "类型:" + str + "-----地址:" + address + "-----时间:" + new Date(date) + "------内容:" + body);
                }
                cursor.close();
                return smsList;
            }
            return null;
        }

    写假短信代码(在短信列表中直接加入):

    1 public void writeSMS() {
    2         ContentResolver resolver = this.getContentResolver();
    3         ContentValues values = new ContentValues();
    4         values.put("address", "10086");
    5         values.put("date", System.currentTimeMillis());
    6         values.put("type", "1");
    7         values.put("body", "送你100元话费!");
    8         resolver.insert(Uri.parse("content://sms/"), values);
    9     }
  • 相关阅读:
    DOM元素的位置、尺寸及更多的信息
    BASE1(matlab)
    安装 sublime package control
    php 排序
    highstock
    html5 压缩图片 上传
    2016012016+小学四则运算练习软件项目报告
    构建之法初次阅读之1,2,16章
    一段异步操作的代码(清理缓存)
    计算两点距离 ios
  • 原文地址:https://www.cnblogs.com/zzw1994/p/4913896.html
Copyright © 2011-2022 走看看