AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.Texting Class Reference
Inheritance diagram for com.google.appinventor.components.runtime.Texting:
com.google.appinventor.components.runtime.ActivityResultListener com.google.appinventor.components.runtime.Deleteable com.google.appinventor.components.runtime.OnStopListener com.google.appinventor.components.runtime.util.OnInitializeListener com.google.appinventor.components.runtime.OnPauseListener com.google.appinventor.components.runtime.OnResumeListener com.google.appinventor.components.runtime.Component com.google.appinventor.components.runtime.AndroidNonvisibleComponent

Classes

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 com.google.appinventor.components.runtime.AndroidNonvisibleComponent
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 = "com.google.android.apps.googlevoice.SMS_RECEIVED"
 
static final String PHONE_NUMBER_TAG = "com.google.android.apps.googlevoice.PHONE_NUMBER"
 
static final String MESSAGE_TAG = "com.google.android.apps.googlevoice.TEXT"
 
static final String TELEPHONY_INTENT_FILTER = "android.provider.Telephony.SMS_RECEIVED"
 
static final String GV_INTENT_FILTER = "com.google.android.apps.googlevoice.SMS_RECEIVED"
 
static final String GV_PACKAGE_NAME = "com.google.android.apps.googlevoice"
 
static final String GV_SMS_SEND_URL = "https://www.google.com/voice/b/0/sms/send/"
 
static final String GV_URL = "https://www.google.com/voice/b/0/redirection/voice"
 
static final String META_DATA_SMS_KEY = "sms_handler_component"
 
static final String META_DATA_SMS_VALUE = "Texting"
 
- Static Public Attributes inherited from com.google.appinventor.components.runtime.Component
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 ACCELEROMETER_SENSITIVITY_WEAK = 1
 
static final int ACCELEROMETER_SENSITIVITY_MODERATE = 2
 
static final int ACCELEROMETER_SENSITIVITY_STRONG = 3
 
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_LTGRAY = "&HFFCCCCCC"
 
static final String DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF"
 
static final String DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800"
 
static final String DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF"
 
static final String DEFAULT_VALUE_COLOR_RED = "&HFFFF0000"
 
static final String DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF"
 
static final String DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00"
 
static final String DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000"
 
static final float FONT_DEFAULT_SIZE = 14
 
static final int LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL
 
static final int LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL
 
static final int SCALING_SCALE_PROPORTIONALLY = 0
 
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
 
static float SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = ""
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = ""
 

Additional Inherited Members

- Protected Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
 AndroidNonvisibleComponent (Form form)
 
- Protected Attributes inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
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
markf.nosp@m.@goo.nosp@m.gle.c.nosp@m.om (Mark Friedman)
ram86.nosp@m.47@g.nosp@m.mail..nosp@m.com (Ralph Morelli)

Definition at line 169 of file Texting.java.

Constructor & Destructor Documentation

◆ Texting()

com.google.appinventor.components.runtime.Texting.Texting ( ComponentContainer  container)

Creates a new TextMessage component.

Parameters
containerignored (because this is a non-visible component)

Definition at line 254 of file Texting.java.

Member Function Documentation

◆ getCachedMsgCount()

static int com.google.appinventor.components.runtime.Texting.getCachedMsgCount ( )
static

Used to keep count in Notifications.

Returns
message count

Definition at line 695 of file Texting.java.

◆ getMessagesFromIntent()

static SmsMessage [] com.google.appinventor.components.runtime.Texting.getMessagesFromIntent ( Intent  intent)
static

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.

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

Definition at line 612 of file Texting.java.

◆ GoogleVoiceEnabled() [1/2]

boolean com.google.appinventor.components.runtime.Texting.GoogleVoiceEnabled ( )

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.

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

Definition at line 487 of file Texting.java.

◆ GoogleVoiceEnabled() [2/2]

void com.google.appinventor.components.runtime.Texting.GoogleVoiceEnabled ( boolean  enabled)

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

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

Definition at line 508 of file Texting.java.

◆ handledReceivedMessage()

static void com.google.appinventor.components.runtime.Texting.handledReceivedMessage ( Context  context,
String  phone,
String  msg 
)
static

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

Parameters
phone
msg

Definition at line 727 of file Texting.java.

◆ Initialize()

void com.google.appinventor.components.runtime.Texting.Initialize ( )

Definition at line 312 of file Texting.java.

◆ isReceivingEnabled()

static int com.google.appinventor.components.runtime.Texting.isReceivingEnabled ( Context  context)
static

Definition at line 591 of file Texting.java.

◆ isRunning()

static boolean com.google.appinventor.components.runtime.Texting.isRunning ( )
static

Called by SmsBroadcastReceiver

Returns
isRunning if the app is running in the foreground.

Definition at line 687 of file Texting.java.

◆ Message() [1/2]

String com.google.appinventor.components.runtime.Texting.Message ( )

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

Definition at line 367 of file Texting.java.

◆ Message() [2/2]

void com.google.appinventor.components.runtime.Texting.Message ( 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.

Parameters
messagethe message to send when the SendMessage function is called.

Definition at line 357 of file Texting.java.

◆ MessageReceived()

static void com.google.appinventor.components.runtime.Texting.MessageReceived ( String  number,
String  messageText 
)
static

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.

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

Definition at line 457 of file Texting.java.

◆ onDelete()

void com.google.appinventor.components.runtime.Texting.onDelete ( )

◆ onInitialize()

void com.google.appinventor.components.runtime.Texting.onInitialize ( )

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

Implements com.google.appinventor.components.runtime.util.OnInitializeListener.

Definition at line 302 of file Texting.java.

◆ onPause()

void com.google.appinventor.components.runtime.Texting.onPause ( )

Messages received while paused will be cached

Implements com.google.appinventor.components.runtime.OnPauseListener.

Definition at line 717 of file Texting.java.

◆ onResume()

void com.google.appinventor.components.runtime.Texting.onResume ( )

Processes cached messages if the app is initialized

Implements com.google.appinventor.components.runtime.OnResumeListener.

Definition at line 703 of file Texting.java.

◆ onStop()

void com.google.appinventor.components.runtime.Texting.onStop ( )

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

Implements com.google.appinventor.components.runtime.OnStopListener.

Definition at line 1223 of file Texting.java.

◆ PhoneNumber() [1/2]

String com.google.appinventor.components.runtime.Texting.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.

Definition at line 343 of file Texting.java.

◆ PhoneNumber() [2/2]

void com.google.appinventor.components.runtime.Texting.PhoneNumber ( String  phoneNumber)

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

Parameters
phoneNumbera phone number to call

Definition at line 326 of file Texting.java.

◆ ReceivingEnabled() [1/2]

int com.google.appinventor.components.runtime.Texting.ReceivingEnabled ( )

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

@suppressdoc

Returns
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 Texting.java.

◆ ReceivingEnabled() [2/2]

void com.google.appinventor.components.runtime.Texting.ReceivingEnabled ( 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.

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

Definition at line 572 of file Texting.java.

◆ resultReturned()

void com.google.appinventor.components.runtime.Texting.resultReturned ( int  requestCode,
int  resultCode,
Intent  data 
)

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

Parameters
requestCodethe originally passed in request code. Used to identify the call.
resultCodethe returned result code: android.app.Activity#RESULT_OK or android.app.Activity#RESULT_CANCELED
datathe returned data, encapsulated as an Intent.

Implements com.google.appinventor.components.runtime.ActivityResultListener.

Definition at line 762 of file Texting.java.

◆ SendMessage()

void com.google.appinventor.components.runtime.Texting.SendMessage ( )

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

Definition at line 375 of file Texting.java.

◆ SendMessageDirect()

void com.google.appinventor.components.runtime.Texting.SendMessageDirect ( )

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 Texting.java.

Member Data Documentation

◆ GV_INTENT_FILTER

final String com.google.appinventor.components.runtime.Texting.GV_INTENT_FILTER = "com.google.android.apps.googlevoice.SMS_RECEIVED"
static

Definition at line 185 of file Texting.java.

◆ GV_PACKAGE_NAME

final String com.google.appinventor.components.runtime.Texting.GV_PACKAGE_NAME = "com.google.android.apps.googlevoice"
static

Definition at line 186 of file Texting.java.

◆ GV_SMS_RECEIVED

final String com.google.appinventor.components.runtime.Texting.GV_SMS_RECEIVED = "com.google.android.apps.googlevoice.SMS_RECEIVED"
static

Definition at line 181 of file Texting.java.

◆ GV_SMS_SEND_URL

final String com.google.appinventor.components.runtime.Texting.GV_SMS_SEND_URL = "https://www.google.com/voice/b/0/sms/send/"
static

Definition at line 187 of file Texting.java.

◆ GV_URL

final String com.google.appinventor.components.runtime.Texting.GV_URL = "https://www.google.com/voice/b/0/redirection/voice"
static

Definition at line 188 of file Texting.java.

◆ MESSAGE_TAG

final String com.google.appinventor.components.runtime.Texting.MESSAGE_TAG = "com.google.android.apps.googlevoice.TEXT"
static

Definition at line 183 of file Texting.java.

◆ META_DATA_SMS_KEY

final String com.google.appinventor.components.runtime.Texting.META_DATA_SMS_KEY = "sms_handler_component"
static

Definition at line 193 of file Texting.java.

◆ META_DATA_SMS_VALUE

final String com.google.appinventor.components.runtime.Texting.META_DATA_SMS_VALUE = "Texting"
static

Definition at line 194 of file Texting.java.

◆ PHONE_NUMBER_TAG

final String com.google.appinventor.components.runtime.Texting.PHONE_NUMBER_TAG = "com.google.android.apps.googlevoice.PHONE_NUMBER"
static

Definition at line 182 of file Texting.java.

◆ SMS_RECEIVED

final String com.google.appinventor.components.runtime.Texting.SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED"
static

Definition at line 180 of file Texting.java.

◆ TAG

final String com.google.appinventor.components.runtime.Texting.TAG = "Texting Component"
static

Definition at line 173 of file Texting.java.

◆ TELEPHONY_INTENT_FILTER

final String com.google.appinventor.components.runtime.Texting.TELEPHONY_INTENT_FILTER = "android.provider.Telephony.SMS_RECEIVED"
static

Definition at line 184 of file Texting.java.

◆ TEXTING_REQUEST_CODE

final int com.google.appinventor.components.runtime.Texting.TEXTING_REQUEST_CODE = 0x54455854
static

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

Definition at line 178 of file Texting.java.


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