AI2 Component  (Version nb184) Class Reference
Inheritance diagram for


class  AsyncAuthenticate
class  AsyncSendMessage
class  GoogleVoiceUtil

Public Member Functions

 Texting (ComponentContainer container)
void onInitialize ()
void Initialize ()
void PhoneNumber (String phoneNumber)
String PhoneNumber ()
void Message (String message)
String Message ()
void SendMessage ()
void SendMessageDirect ()
boolean GoogleVoiceEnabled ()
void GoogleVoiceEnabled (boolean enabled)
int ReceivingEnabled ()
void ReceivingEnabled (int enabled)
void onResume ()
void onPause ()
void resultReturned (int requestCode, int resultCode, Intent data)
void onStop ()
void onDelete ()
- Public Member Functions inherited from
HandlesEventDispatching getDispatchDelegate ()

Static Public Member Functions

static void MessageReceived (String number, String messageText)
static int isReceivingEnabled (Context context)
static SmsMessage[] getMessagesFromIntent (Intent intent)
static boolean isRunning ()
static int getCachedMsgCount ()
static void handledReceivedMessage (Context context, String phone, String msg)

Static Public Attributes

static final String TAG = "Texting Component"
static final int TEXTING_REQUEST_CODE = 0x54455854
static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED"
static final String GV_SMS_RECEIVED = ""
static final String PHONE_NUMBER_TAG = ""
static final String MESSAGE_TAG = ""
static final String TELEPHONY_INTENT_FILTER = "android.provider.Telephony.SMS_RECEIVED"
static final String GV_INTENT_FILTER = ""
static final String GV_PACKAGE_NAME = ""
static final String GV_SMS_SEND_URL = ""
static final String GV_URL = ""
static final String META_DATA_SMS_KEY = "sms_handler_component"
static final String META_DATA_SMS_VALUE = "Texting"
- Static Public Attributes inherited from
static final String ASSET_DIRECTORY = "component"
static final int ALIGNMENT_NORMAL = 0
static final int ALIGNMENT_CENTER = 1
static final int ALIGNMENT_OPPOSITE = 2
static final int BUTTON_SHAPE_DEFAULT = 0
static final int BUTTON_SHAPE_ROUNDED = 1
static final int BUTTON_SHAPE_RECT = 2
static final int BUTTON_SHAPE_OVAL = 3
static final int COLOR_NONE = 0x00FFFFFF
static final int COLOR_BLACK = 0xFF000000
static final int COLOR_BLUE = 0xFF0000FF
static final int COLOR_CYAN = 0xFF00FFFF
static final int COLOR_DKGRAY = 0xFF444444
static final int COLOR_GRAY = 0xFF888888
static final int COLOR_GREEN = 0xFF00FF00
static final int COLOR_LTGRAY = 0xFFCCCCCC
static final int COLOR_MAGENTA = 0xFFFF00FF
static final int COLOR_ORANGE = 0xFFFFC800
static final int COLOR_PINK = 0xFFFFAFAF
static final int COLOR_RED = 0xFFFF0000
static final int COLOR_WHITE = 0xFFFFFFFF
static final int COLOR_YELLOW = 0xFFFFFF00
static final int COLOR_DEFAULT = 0x00000000
static final String DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF"
static final String DEFAULT_VALUE_COLOR_BLACK = "&HFF000000"
static final String DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF"
static final String DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF"
static final String DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444"
static final String DEFAULT_VALUE_COLOR_GRAY = "&HFF888888"
static final String DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00"
static final String DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800"
static final String DEFAULT_VALUE_COLOR_RED = "&HFFFF0000"
static final String DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000"
static final float FONT_DEFAULT_SIZE = 14
static final int SCALING_SCALE_TO_FIT = 1
static final int TYPEFACE_DEFAULT = 0
static final int TYPEFACE_SANSSERIF = 1
static final int TYPEFACE_SERIF = 2
static final int TYPEFACE_MONOSPACE = 3
static final int LENGTH_PREFERRED = -1
static final int LENGTH_FILL_PARENT = -2
static final int LENGTH_UNKNOWN = -3
static final int LENGTH_PERCENT_TAG = -1000
static final int TOAST_LENGTH_SHORT = 0
static final int TOAST_LENGTH_LONG = 1
static final int DIRECTION_NORTH = 1
static final int DIRECTION_NORTHEAST = 2
static final int DIRECTION_EAST = 3
static final int DIRECTION_SOUTHEAST = 4
static final int DIRECTION_SOUTH = -1
static final int DIRECTION_SOUTHWEST = -2
static final int DIRECTION_WEST = -3
static final int DIRECTION_NORTHWEST = -4
static final int DIRECTION_NONE = 0
static final int DIRECTION_MIN = -4
static final int DIRECTION_MAX = 4
static float SLIDER_MIN_VALUE = 10
static float SLIDER_MAX_VALUE = 50

Additional Inherited Members

- Protected Member Functions inherited from
 AndroidNonvisibleComponent (Form form)
- Protected Attributes inherited from
final Form form

Detailed Description

Texting component icon

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(String, String) 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.

Author (Mark Friedman) (Ralph Morelli)

Definition at line 169 of file

Constructor & Destructor Documentation

◆ Texting() ( ComponentContainer  container)

Creates a new TextMessage component.

containerignored (because this is a non-visible component)

Definition at line 254 of file

Member Function Documentation

◆ getCachedMsgCount()

static int ( )

Used to keep count in Notifications.

message count

Definition at line 695 of file

◆ getMessagesFromIntent()

static SmsMessage [] ( Intent  intent)

Parse the messages out of the extra fields from the "android.permission.RECEIVE_SMS" broadcast intent.

Note: This code was copied from the Android android.provider.Telephony.Sms.Intents class.

intentthe intent to read from
an array of SmsMessages for the PDUs

Definition at line 612 of file

◆ GoogleVoiceEnabled() [1/2]

boolean ( )

If true, then SendMessage() will attempt to send messages over Wifi using Google Voice. This requires that the Google Voice app must be installed and set up on the phone or tablet, with a Google Voice account. If GoogleVoiceEnabled is false, the device must have phone and texting service in order to send or receive messages with this component. Google Voice is available only in the USA, and some phone networks do not support it.

'true' or 'false' depending on whether you want to use Google Voice for sending/receiving messages.

Definition at line 487 of file

◆ GoogleVoiceEnabled() [2/2]

void ( boolean  enabled)

If this property is true, then SendMessage will attempt to send messages over WiFi, using Google voice.

enabledSet to 'true' or 'false' depending on whether you want to use Google Voice to send/receive messages.

Definition at line 508 of file

◆ handledReceivedMessage()

static void ( Context  context,
String  phone,
String  msg 

This method is called by SmsBroadcastReceiver when a message is received.


Definition at line 727 of file

◆ Initialize()

void ( )

Definition at line 312 of file

◆ isReceivingEnabled()

static int ( Context  context)

Definition at line 591 of file

◆ isRunning()

static boolean ( )

Called by SmsBroadcastReceiver

isRunning if the app is running in the foreground.

Definition at line 687 of file

◆ Message() [1/2]

String ( )

The text message that will be sent when the SendMessage method is called. @suppressdoc

Definition at line 367 of file

◆ Message() [2/2]

void ( String  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.

messagethe message to send when the SendMessage function is called.

Definition at line 357 of file

◆ MessageReceived()

static void ( String  number,
String  messageText 

Event that's raised when a text message is received by the phone. Using this block will add dangerous permissions that will require additional approval if your app is submitted to the Google Play Store.

numberthe phone number that the text message was sent from.
messageTextthe text of the message.

Definition at line 457 of file

◆ onDelete()

void ( )

◆ onInitialize()

void ( )

Callback from Form. No incoming messages can be processed through MessageReceived until the Form is initialized. Messages are cached until this method is called.


Definition at line 302 of file

◆ onPause()

void ( )

Messages received while paused will be cached


Definition at line 717 of file

◆ onResume()

void ( )

Processes cached messages if the app is initialized


Definition at line 703 of file

◆ onStop()

void ( )

Save the component's state in shared preference file before it is killed.


Definition at line 1223 of file

◆ PhoneNumber() [1/2]

String ( )

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.

Definition at line 343 of file

◆ PhoneNumber() [2/2]

void ( String  phoneNumber)

Sets the phone number to send the text message to when the SendMessage function is called.

phoneNumbera phone number to call

Definition at line 326 of file

◆ ReceivingEnabled() [1/2]

int ( )

Gets whether you want the MessageReceived(String,String) event to get run when a new text message is received.


1,2 or 3 indicating that receiving is disabled (1) or foreground only (2) or always (3). MessageReceived(String,String) event to get run when a new text message is received.

Definition at line 541 of file

◆ ReceivingEnabled() [2/2]

void ( int  enabled)

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(String, String) event. Messages received when the app is dormant will be queued, and so several MessageReceived(String, String) 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.

enabled0 = never receive, 1 = receive foreground only, 2 = receive always

Definition at line 572 of file

◆ resultReturned()

void ( int  requestCode,
int  resultCode,
Intent  data 

The callback method used to report Activity results back to the caller.

requestCodethe originally passed in request code. Used to identify the call.
resultCodethe returned result code: or
datathe returned data, encapsulated as an Intent.


Definition at line 762 of file

◆ SendMessage()

void ( )

Launch the phone's default text messaging app with the message and phone number prepopulated.

Definition at line 375 of file

◆ SendMessageDirect()

void ( )

Send a text message. Using this block will add dangerous permissions that will require additional approval if your app is submitted to the Google Play Store.

Definition at line 395 of file

Member Data Documentation


final String = ""

Definition at line 185 of file


final String = ""

Definition at line 186 of file


final String = ""

Definition at line 181 of file


final String = ""

Definition at line 187 of file


final String = ""

Definition at line 188 of file


final String = ""

Definition at line 183 of file


final String = "sms_handler_component"

Definition at line 193 of file


final String = "Texting"

Definition at line 194 of file


final String = ""

Definition at line 182 of file


final String = "android.provider.Telephony.SMS_RECEIVED"

Definition at line 180 of file


final String = "Texting Component"

Definition at line 173 of file


final String = "android.provider.Telephony.SMS_RECEIVED"

Definition at line 184 of file


final int = 0x54455854

Magic number "TEXT" used to report when a text message has been sent.

Definition at line 178 of file

The documentation for this class was generated from the following file: