- Initial version.
Having apps that can do things in the background has been one of the most asked for App Inventor features, see also
After going through the different SMS Text tutorials you will realize, that they do not work anymore if the device is sleeping. The Google Voice intergration was a nice feature, see also the Alert Me tutorial, however this works only in the United States and not elsewhere in the world.
As workaround, I therefore put together a Java app SMS Receiver using parts of the source from here and a small App Inventor test project smstest.apk, which will be started after a SMS has been received.
Each time a SMS is received, SMS Receiver checks, if the App Inventor app needs to be started depending on the stored settings:
This also still works after rebooting the device. Thank you lisisoft.com for the app icon.
In the example the SMS with the message "Woo Hoo!" has been sent to the device. The phone number and message will be sent to the App Inventor app in the following format: <phone number>|||<message>. You will find that info in the "get plain start text" block.
LogCat after a message has been received
In the example the trigger SMS has been sent to the device. Only the phone number will be sent to the App Inventor app in this case. You will find it in the "get plain start text" block.
LogCat after the trigger message has been received
LogCat after another message has been received
Q1:Tried to run SMS Receiver on my Sony xperia z as I want to buy the live version to call my sms app - it keeps crashing.
A: Make sure to use the correct package name of your app like this: appinventor.ai_YOURLOGINNAME.YOURPROJECTNAME
You also can find out the package name like this: Download the source code of your App Inventor project to your computer. Using a file explorer or unzip utility, find the file called youngandroidproject/project.properties. The first line will start with "main=". Everything after that is the package and class name.
For example, here is a first line you might see for an App named HelloPurr: main=appinventor.ai_ElsaArendelle.HelloPurr.Screen1
The ElsaArendelle part of the name comes from the App Inventor user account. The package name in the example is appinventor.ai_ElsaArendelle.HelloPurr
Q2: I sent trigger text message "puravida" all worked as it should. Then I changed SMSReceiver to "start AppInventor app for all messages" and sent text message - SMS Test opens with blank screen. Is this correct?
A: Make sure to close your app before doing the test. The smstest app should display a notifier after a message has been received, see screenshots above.
Q3: I was wondering, does this work on AI2LiveComplete?
A: The SMS Receiver app can start any Android app, this can be a MIT App Inventor app, an AiLiveComplete App Inventor app or any other Android app developed with Eclipse or Android Studio or other development environments.
Q4: Is it possible to just start the app without the Phone noticing it got a sms? Just start the app in the background when the phone is asleep?
A: No, you default sms app will always receive the sms.
The test version of the SMS Receiver app
will work for a while. After that, a message will be sent to the App Inventor app. You can continue using the
test version of the SMS Receiver app
after deleting its data.