0

Есть ресивер на получение смс. Нужно проверить номер отправителя, и если он равен переменной удалить эту смс. Вопрос, как реализовать?

1 ответ 1

1
private int deleteMessage(Context context, SmsMessage msg) {
    Uri deleteUri = Uri.parse("content://sms");
    int count = 0;
    Cursor c = context.getContentResolver().query(deleteUri, null, null,
            null, null);
    while (c.moveToNext()) {
        try {
            // Delete the SMS
            String pid = c.getString(0); // Get id;
            String uri = "content://sms/" + pid;
            count = context.getContentResolver().delete(Uri.parse(uri),
                    null, null);
        } catch (Exception e) {
        }
    }
    return count;
}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.