If you get a send error on your phone is the app able to recognize it?

Hi Folks,

I have an app that will send a text message to a contact when a signal is not recieved to say that i am in trouble ..

However if for some reason the message has not sent (no credit for example) can MIT see this?

Can I tell the app if message not sent lets say 3 times - ring the police? (I won't ring the police I'll use like 1234) .. This is for a College project so just trying to see can it be done in theory :slight_smile: ..

As always any help would be greatly appreciated ..

1 Like

Android definitely recognizes sending errors, because various sms apps show sending error. But I'm not sure if there is a proper implementation in appInventor. Have you tried using the ErrorOccured event block from the Screen1 drawer?
Then do a test by sending a message to the wrong number, or without funds on the prepaid account.


I tried using the Screen 1 error occured event tonight.
The problem is I'm not to sure how best to trigger the event.

I was thinking the error number might be best - the error I get is "Generic Failure - message not sent".
However I'm not sure what Android error code would work for this. I have tired 1 but no luck ..

I was using this Error Occured Event for no connection of Bluetooth and was using the code 516 for this.

As always any help or insight would be greatly appreciated.


Such errors or information may occur in the case of the Texting component:

case Activity.RESULT_OK:
        Log.i(TAG, "Received OK, msg:" + smsMsg);
        Toast.makeText(activity, "Message sent", Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Received generic failure, msg:" + smsMsg);
        Toast.makeText(activity, "Generic failure: message not sent", Toast.LENGTH_SHORT).show();
      case SmsManager.RESULT_ERROR_NO_SERVICE:
        Log.e(TAG, "Received no service error, msg:"  + smsMsg);
        Toast.makeText(activity, "No Sms service available. Message not sent.", Toast.LENGTH_SHORT).show();
      case SmsManager.RESULT_ERROR_NULL_PDU:
        Log.e(TAG, "Received null PDU error, msg:"  + smsMsg);
        Toast.makeText(activity, "Received null PDU error. Message not sent.", Toast.LENGTH_SHORT).show();
      case SmsManager.RESULT_ERROR_RADIO_OFF:
        Log.e(TAG, "Received radio off error, msg:" + smsMsg);
        Toast.makeText(activity, "Could not send SMS message: radio off.", Toast.LENGTH_LONG).show();

So to handle the error just compare the text.

Sorry Patryk, you will have to excuse my ignorance - is this coding for the microcontroller (Arduino IDE) or is this something in MIT app inventor?

Sorry we are working beyond my capabilities now for sure :frowning:


As we can see from the code snippet provided by @Patryk_F , the texting component unfortunately does not trigger the ErrorOccurred event... it displays only a toast message in case of an error,
so there currently is no way to detect this programmatically... @ewpatton might think about adjusting this...


1 Like

Thanks Taifun,

I'm following now :slight_smile:
Thanks again for the help folks ..