Recently, I have been doing some further development on Android App Inventor. My focus for this work was getting the application to send and receive SMS messages. To aid others in doing this I put together this tutorial which shows this.
The first part of the tutorial shows how to send an SMS from within an App Inventor App. This is relatively simple and requires a a couple of text boxes (Mobile Number & Message Text) and a button to press to send the message.
You will also need to add a non-visual Texting component to the form.
Once the form has been created, the Blocks required to send a message should be configured as in the following image.
This block of code is executed when the user clicks the Send Message button. The first two actions are to set the Mobile Number and Message text on the Texting object to the values in the text boxes.
The last action calls the Texting.SendMessage method to actually send an SMS. Simple.
Note: This code does not do any error checking or validation. Erroneous data may cause the application to Force Close.
The second part of the tutorial will show how to make an App Inventor application respond to an SMS that it receives. For this application there is no GUI as the application handles the logic in the background. All we need are some blocks to intercept the SMS messages received.
This block of code is executed when the phone gets a SMS message.
The MessageRecieved method exposes two values: number and messageText. You can store these in a couple of variables.
The second thing this block does is to check the message to see if it contains the text 'Status?' If this text is in the message it will create a new TextMessage using the received number and respond with the message 'All Good!'. This is a simple application for this but could be used for such things as responding with a user location or responding with a simple message if the user is unavailable.
I hope this tutorial has been helpful. Please feel free to comment if you need further information.
I have added a link to the source code here.
My other App Inventor tutorials:
App Inventor - Location Services
App Inventor - Lists
60 of our biggest AI announcements in 2024
2 days ago