如何在不保存在收件箱或已发送文件夹中的情况下发送短信 - Android

How can I send SMS without save in inbox or sent folders - Android

如何在 android 中不保存收件箱或发送文件夹的情况下发送短信?

当我使用此代码时,邮件保存在已发送文件夹中:

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber, null, messageBody, null, null);

但我想在后台发送消息。

您的应用 运行 android 4.4 及更高版本吗?

从Android 4.4开始,发送的短信不显示在发件箱中。

大纲在https://developer.android.com/about/versions/android-4.4.html#SMS你可以看到变化。

SMS Provider The Telephony content provider (the "SMS Provider") allows apps to read and write SMS and MMS messages on the device. It includes tables for SMS and MMS messages received, drafted, sent, pending, and more.

Beginning with Android 4.4, the system settings allow users to select a "default SMS app." Once selected, only the default SMS app is able to write to the SMS Provider and only the default SMS app receives the SMS_DELIVER_ACTION broadcast when the user receives an SMS or the WAP_PUSH_DELIVER_ACTION broadcast when the user receives an MMS. The default SMS app is responsible for writing details to the SMS Provider when it receives or sends a new message.

Other apps that are not selected as the default SMS app can only read the SMS Provider, but may also be notified when a new SMS arrives by listening for the SMS_RECEIVED_ACTION broadcast, which is a non-abortable broadcast that may be delivered to multiple apps. This broadcast is intended for apps that---while not selected as the default SMS app---need to read special incoming messages such as to perform phone number verification.

有关详细信息,请阅读博客 post,让您的 SMS 应用程序为 KitKat 做好准备。http://android-developers.blogspot.my/2013/10/getting-your-sms-apps-ready-for-kitkat.html