App Inventor and Java


How to start an App Inventor app after a SMS has been received

Having apps that can do things in the background has been one of the most asked for App Inventor features, see also issue 32.

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.

Version History

How does it work?

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.


Some Notes:

Start App Inventor app for all messages

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


Start App Inventor app only for trigger message

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

Do you need help with your App Inventor project?

I can help you: for one hour I charge 25 USD.
Please contact me at info [at] puravidaapps [dot] com for details!
For questions about App Inventor, please use the App Inventor forum. Thank you.

App Inventor blocks


Questions and Answers

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.

Download and Test with the test version of the SMS Receiver app

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.

Download App Inventor test project
Download test version of the SMS Receiver app

Buy the full version of the SMS Receiver app


You can buy the full version of this project.
With your payment you accept the terms and conditions below.

Please transfer 10$ and tell me the project name you are interested in
and I will be happy to send the full version to you.

Thank you! Taifun
 

Terms and Conditions

Back to top of page ...


Home | Snippets | Tutorials | Extensions | News | Forums | Links | Search | Contact