Good morning, can you kindly tell me or post me a simple app made with app inventor that can send and receive a text message. Also on Samsung Smartphone what must be done to activate this app and not the standard one of the phone? Thanks in advance. Best regards. Paolo
simple app made with app inventor that can send and receive a text message.
[/quote]
[quote="pdecaro, post:1, topic:143237"]
none are simple.
Here is an example you might simplify
https://ai2.appinventor.mit.edu/reference/components/social.html#Texting
Using the Texting component you can only use the standard texting app as that is what using the component does.
Thanks Steve for your reply, but if you can kindly send me an example or a photo of the block code of how to receive a simple sms from android, and what needs to be activated on a Samsung smartphone to view it on the app, I would be very grateful. Excellent example of the position you posted. I need a simple example that can receive a SMS. Thanks again. Best regards. Paolo
Use the Message Received event
This will work if your app is in the foreground
This will not replace your default sms app
Here is an example App Inventor Tutorials and Examples: Get Phone Number | Pura Vida Apps
Taifun
Good morning everyone, I wrote this simple app that I attach to receive a simple SMS, but it does not display received SMS. I gave SMS permissions from my Samsung A23 Smartphone.
Can you kindly help me understand why it does not display SMS?
Thank you all.
show your relevant blocks here.
What did you set Texting.ReceivingEnabled to in your program? To enable MessagedReceived you have to set it to something other than 1. If it is set to 1 you won't receive any messages when sms texts are received.
ReceivingEnabled
If set to 1 (OFF) no messages will be received. If set to 2 (FOREGROUND) or 3 (ALWAYS) the component will respond to messages if it is running. In the case of 2 (FOREGROUND), messages received while the app is not running are discarded. In the case of 3 (ALWAYS), messages receive while the app is not running will show a notification. Selecting the notification will bring up the app and signal the MessageReceived
event. Messages received when the app is dormant will be queued, and so several MessageReceived
events might appear when the app awakens. As an app developer, it would be a good idea to give your users control over this property, so they can make their phones ignore text messages when your app is installed.
Ask for permission android.permission.RECEIVE_SMS in the Screen Initialize event
Build your app, install it and open the app, then receive an SMS to test
If you want to receive a SMS while your app is in the background, then this extension might be interesting for you
Taifun
Good evening Steve and thanks for your reply. But the Terxting parameter is already set as Foreground. I attach photos. Let me know if it's ok.
This looks ok. Now
Taifun
Hi Taifun thanks for your reply, but the parameter that you suggest to put "android.permission.RECEIVE.SMS" is already inserted in the manifest.xml. I attach a photo.
@pdecaro as far as I know GoogleVoiceEnabled cannot be used any more. To Text you need to use Companion and a real Android cell phone.
I'm working on an example. It is working on a Samsung A13 (Android 13) to receive texts from others just fine.
I'll post an aia as soon as I can; probably sometime tomorrow.

Regards,
Steve
Yes
But you have to additionally use the AskForPermission method from the Screen drawer to ask for that permission
To only have the permission in the manifest is not sufficient
Taifun
Hi Tafun and thanks again for your availability, I did as you asked, but it doesn't work. I always receive text messages with the standard Samsung app and not with my application. I'm desperate, help me. Thanks I have a Samsung A23 with Android version 14. here is the current block. Help
Yes, you always will receive the sms with the standard Samsung app, but if you test correctly, then additionally you will receive it in your app
Taifun
But this code does work. on my Samsung. It should work on your samsung.
This is a test application to show the Texting component works for both sms sending and receiving.
The app must be compiled to test. Live testing with Companion 2.74u spawns errors.
Sending SMS
- it needs probably android.permission.SEND_SMS and android.permission.RECEIVE_SMS in the Screen1.Initialize.
- The Buttons that control ReceivingEnabled work while the app is active (yes you can change behavior, at least on my hardware.) The ALWAYS Button is there in the aia Project; just set to visible
- the demo app is simple. The user has to key in (type) the phone number he/she wants to Text to. Another way to specify a phone number is to include a PhoneNumberPicker component, to let the users select a phone numbers from the ones stored in the the phone’s contacts.
- after typing both the phone number AND message the Send Text button will send the text to its intended destination.
Receiving SMS
- if ReceivingEnabled is NOT 1, it will display texts sent to you. It will show the text from phone number and the message (see the largest red star)
- ReceivingEnabled must be set to 2 or 3 to display incoming sms messages in the app.
- if ReceivingEnabled is 2 or 3 it will display texts you receive as described in the MIT documentation.
- Unfortunately, receiving no longer works with Google Voice in Tablets due to changes introduced in Google Voice App indicated in the control's documentation. This means receiving sms will not work on a Tablet that does not have phone capability. It will only send text on my older Samsung Tab A if I install GV.
- the app also will not work with an emulator.
- any Receiving message will overwrite the message currently in received message Label. You can code that.
- When used in Foreground mode and a text message arrives, a notification pops up briefly and the MessageReceived block posts the phone number and message to the Label in the app (show the arriving SMS message). If the phone receives a text message when the app is not in the foreground, the phone will show a notification in the notification bar. Selecting the notification will bring up the app ( didn't test if selecting works. I did not spend time with ALWAYS).
Error Control
- this example is simple. Very little code was provided to prevent a user from sending incomplete messages. The code tries to make sure there is a phone number entered and a message to use as a text etc. If you don't provide error control, the app can crash. That need not happen. You can fix that with if..then statements and other coding.
- the app works ONLY when compiled. When using Companion 2.74u it spawns an unable to create GVhelper I/O error message.
- I tested on an Android 13 cell an Android 8.1 tablet. The Android 13 cell works fine. However I don't have GV installed on the tablet which is required to send messages over wifi . GV must be installed and the user has to have a GV account so I couldn't test to send messages on the tablet.
- to get the SendMessageDirect coding block visible in your Project Design screen you have to use Companion 2.74u version. Using this block add "dangerous permissions" that will require additional approval if your app is submitted to the Google Play Store. The SMD block is necessary to be able to send a direct message.
- the code contains code to help ensure using a proper phone number and that there is a message available to send.
smsSendReceiveSimple.aia (5.0 KB)
Regards,
Steve
For this to work on devices >= Android 14, you additionally have to ask for post notification permission.
The MelonNotification extension offers a method for that and also adds the corresponding permission into the manifest
Taifun
Hi Steve and thanks again. I coded a simple program simplifying it a bit.
So SEND sms is ok, but reception is not, it always happens with the standard mode of the phone. I attach my app. In my opinion there is something to enable for direct reception of the sms. but what?
I also tried with your program as is and it doesn't work the same.
Yes
As already explained earlier
Taifun