Texting
Definition
A component that will, when the SendMessage
method is called, launch the device’s preferred texting app to send the text message specified in the SendMessage
property to the phone number specified in the PhoneNumber
property. You may also send text messages without user interaction by calling SendMessageDirect
instead, but this adds dangerous permissions to your final app.
If the ReceivingEnabled
property is set to 1 messages will not be received. If ReceivingEnabled
is set to 2 messages will be received only when the application is running. Finally if ReceivingEnabled
is set to 3, messages will be received when the application is running and when the application is not running they will be queued and a notification displayed to the user.
When a message arrives, the MessageReceived
event is raised and provides the sending number and message.
An app that includes this component will receive messages even when it is in the background (i.e. when it’s not visible on the screen) and, moreso, even if the app is not running, so long as it’s installed on the phone. 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. As an app developer, you’ll probably want to give your users the ability to control ReceivingEnabled so that they can make the phone ignore text messages.
If the GoogleVoiceEnabled
property is true, messages can be sent over Wifi using Google Voice. This option requires that the user have a Google Voice account and that the mobile Voice app is installed on the phone. The Google Voice option works only on phones that support Android 2.0 (Eclair) or higher. Unfortunately, receiving no longer works in Google Voice due to changes introduced in Google Voice App.
To specify the phone number (e.g., 650-555-1212), set the PhoneNumber property to a Text string with the specified digits (e.g., 6505551212). Dashes, dots, and parentheses may be included (e.g., (650)-555-1212) but will be ignored; spaces may not be included.
Another way for an app to specify a phone number would be to include a PhoneNumberPicker
component, which lets the users select a phone numbers from the ones stored in the the phone’s contacts.
Properties
- GoogleVoiceEnabled
- If this property is true, then SendMessage will attempt to send messages over WiFi, using Google voice.
- Message
- The message that will be sent when the
SendMessage
method is called. The maximum length of a standard SMS message is usually 170. It may be less for languages using diacritical marks. - PhoneNumber
- The number that the message will be sent to when the SendMessage method is called. The number is a text string with the specified digits (e.g., 6505551212). Dashes, dots, and parentheses may be included (e.g., (650)-555-1212) but will be ignored; spaces should not be included.
- 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 severalMessageReceived
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.