-1

In my Xamarin.Android app I send SMS using the following code :

send.Click += (s, e) =>
{
    SmsManager.Default.SendTextMessage(number.Text, null, message.Text, null, null);
}

And in another button, I want to check which messages are delivered and which are not, to send undelivered message again.

How can I :

  1. Find messages? Is there an ID (a unique one for each sms) or I should find messages by Number and Text?
  2. Check the status of each message?
Mahdi Tahsildari
  • 13,065
  • 14
  • 55
  • 94

1 Answers1

0

Please try the parameters sentIntent and deliveryIntent. Both are PendingIntents that will be broadcasted upon successful sending and delivery to the recipient. Upon building your intent you can add some id from your app that helps you identify which sms was sent/not sent.

To see how to query the SMSProvider, take a look at this StackOverflow anwer.

The answer above uses Telephony.Sms.Inbox. I suggest trying to access Telephony.Sms.Conversations, which according to the doc contains all sent text-based SMS messages. As the class extends android.provider.Telephony.TextBasedSmsColumns, you should be able to query several error codes and status.

Community
  • 1
  • 1
  • Hi Thomas, Actually I want to check them manually and not on Sent or Delivered. In my app user may send lots of messages and check status the next day. BTW, can you share some code about adding ID to sms and check the status later? – Mahdi Tahsildari May 22 '17 at 08:37
  • I see. Then you need to access the SMS content provider. I have no C# code ready, but you may find the StackOverflow answer helpful I included in my answer above. –  May 22 '17 at 09:08
  • I implemented a query base on the link you provided, it works for message body, address and etc. but not for status. Still struggling...\ – Mahdi Tahsildari May 22 '17 at 09:43
  • Added a few lines to my answer. Maybe the info added is helpful. –  May 22 '17 at 10:20