【问题标题】:how to receive the offline SMS in android programatially如何以编程方式在android中接收离线短信
【发布时间】:2011-09-08 07:12:02
【问题描述】:

如果我的 android 设备已关闭,当时有人正在向我的手机发送短信。 一旦我打开,我想以编程方式获取短信。

这可能吗?

【问题讨论】:

    标签: android sms offline-mode


    【解决方案1】:

    您可以像这样从收件箱中获取短信:

    Uri mSmsinboxQueryUri = Uri.parse("content://sms/inbox");
            Cursor cursor1 = getContentResolver().query(mSmsinboxQueryUri,
                        new String[] { "_id", "thread_id", "address", "person", "date",
                                        "body", "type" }, null, null, null);
            startManagingCursor(cursor1);
            String[] columns = new String[] { "address", "person", "date", "body","type" };
            if (cursor1.getCount() > 0) {
                String count = Integer.toString(cursor1.getCount());
                Log.e("Count",count);
                while (cursor1.moveToNext()){
                    String address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
                    String name = cursor1.getString(cursor1.getColumnIndex(columns[1]));
                    String date = cursor1.getString(cursor1.getColumnIndex(columns[2]));
                    String msg = cursor1.getString(cursor1.getColumnIndex(columns[3]));
                    String type = cursor1.getString(cursor1.getColumnIndex(columns[4]));
                }
            }
    

    【讨论】:

    • 嗨..我不想从收件箱中阅读。我已经做了以下事情。 1.我正在使用 Abortbroadcast 阻止短信。因此,当收到短信时,它会发送到我的接收器。 2. 当我的设备在线时,我可以收到短信。 3.如果我关闭我的手机,我将如何使用我的 Broad casrt 接收器接收短信。?????
    • 我在我的设备上交叉检查了它。当您的设备打开时,您的设备会收到关闭时发送的短信,您的接收器应该会收到它的通知...
    • @VineetShukla 你知道如何统计收件箱中的邮件数量以及每个联系人的邮件数量吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-29
    • 1970-01-01
    • 2012-01-24
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    相关资源
    最近更新 更多