如何在Lollipop上伪造短信?

时间:2015-11-01 17:06:26

标签: android sms android-5.0-lollipop

这是我的代码的一部分,但我不明白为什么它不起作用。我也在清单中设置了正确的权限。

enum Box
{
    Inbox, Sent
}

void AddMessage(String Address, String Message, Time Sent, Box b,
        boolean read)
{

    Uri u = null;

    switch (b)
    {
    case Inbox:
        u = Uri.parse("content://sms/inbox");
        break;
    case Sent:
        u = Uri.parse("content://sms/sent");
        break;
    }

    if (u != null)
    {
        Cursor mCursor = this.getContentResolver().query(u, null, null,
                null, null);

        ContentProviderClient P = this.getContentResolver()
                .acquireContentProviderClient(u);

        ContentValues v = new ContentValues();
        v.put("body", Message);
        v.put("read", read);
        v.put("seen", true);
        v.put("address", Address);
        v.put("date", Sent.toMillis(false));
        v.put("date_sent", Sent.toMillis(false));

        try
        {
            int Thread = -1;
            Uri InsertedMessage = P.insert(u, v);
            Log.d("InsertedURI", InsertedMessage.toString());
            Cursor InsertedMessageCursor = this.getContentResolver().query(
                    InsertedMessage, null, null, null, null);
            getContentResolver().insert(Uri.parse("content://sms/"), v);
            if (InsertedMessageCursor.moveToFirst())
            {
                Thread = InsertedMessageCursor.getInt(InsertedMessageCursor
                        .getColumnIndex("thread_id"));
                Uri MessageThread = Uri.parse("content://mms-sms/threadID/"
                        + Thread);
                Log.d("MessageThread", MessageThread.toString());
                Intent V = new Intent(Intent.ACTION_VIEW);
                V.setData(MessageThread);
                this.startActivity(V);
            }

        } catch (RemoteException e)
        {

            e.printStackTrace();
        }

    }

}

void processIntent(Intent intent)
{
    if (intent == null)
        return;

    if (Intent.ACTION_SENDTO.equals(intent.getAction()))
    {
        String destionationNumber = intent.getDataString();
        destionationNumber = URLDecoder.decode(destionationNumber);
        // clear the string
        destionationNumber = destionationNumber// .replace("-", "")
                .replace("smsto:", "").replace("sms:", "");
        editText_ToFrom.setText(destionationNumber);
    }

}

我的问题是,它没有把短信放在我的短信列表中。我想实现这样的目标: https://play.google.com/store/apps/details?id=com.neurondigital.FakeTextMessage 提前谢谢!

0 个答案:

没有答案