Explore AppyBuilder logo
  • Home
  • Forum ▾
  • Reference ▾
  • Facebook ▾

Connectivity Components - AppyBuilder for Android

Table of Contents

  • ActivityStarter
  • BluetoothClient
  • BluetoothServer
  • Web

ActivityStarter

Picture of Activity Starter component

A component that can launch another activity from your application.

You communicate with the activity starter by setting properties of the component to pass information related to the activity, including the action and activity class. See Using the Activity Starter Component for details and examples.

Activities that can be launched include:

  • Starting another AppyBuilder for Android app. To do so, first determine class of the other application by downloading the source code and using a file explorer or unzip utility to find a file named "youngandroidproject/project.properties". The first line of the file will start with "main=" and be followed by the class name; for example,

    main=com.gmail.Bitdiddle.Ben.HelloPurr.Screen1

    To make your ActivityStarter launch this application, set the following properties:

    • ActivityPackage to the class name, dropping the last component (for example, com.gmail.Bitdiddle.Ben.HelloPurr )
    • ActivityClass to the entire class name (for example, com.gmail.Bitdiddle.Ben.HelloPurr.Screen1 )
  • Starting an activity that is built in to the Android OS, such as using the camera, or performing a web search. You can start camera by setting the following properties:
    • Action: android.intent.action.MAIN
    • ActivityPackage: com.android.camera
    • ActivityClass: com.android.camera.Camera
  • Performing web search: Assuming the term you want to search for is "vampire" (feel free to substitute your own choice), set the properties to:
    • Action: android.intent.action.WEB_SEARCH
    • ExtraKey: query
    • ExtraValue: vampire
    • ActivityPackage: com.google.android.providers.enhancedgooglesearch
    • ActivityClass: com.google.android.providers.enhancedgooglesearch.Launcher
  • Opening a browser to a specified web page. Assuming the page you want to go to is "www.facebook.com" (feel free to substitute your own choice), set the properties to:
    • Action: android.intent.action.VIEW
    • DataUri: http://www.facebook.com

You can also launch third-party applications installed on the phone, provided you know the appropriate intents to invoke them, and you can also launch activities that produce text results and get them back to use in your application. The way this data is extracted depends on how the application has been implemented.

Properties

Action : text
Action of the activity to be launched.
ActivityClass : text
Class name of the activity to be launched.
ActivityPackage : text
Package name of the activity to be launched.
DataUri : text
URI passed to activity to be launched.
ExtraKey : text
Key name of text passed to the activity.
ExtraValue : text
Value of text passed to the activity.
Result : text
Value returned by the activity being started.
ResultName : text
The name used to extract the result returned from the activity being started.
ResultType : text
Type information returned from the activity being started.
ResultUri : text
URI (or Data) information returned from the activity being started.

Events

ActivityError(text message) >
Indicates that an error occurred while using this ActivityStarter.
AfterActivity(text result)
Called after activity ends.

Methods

text ResolveActivity ()
Returns the name of the activity that corresponds to this ActivityStarter, or an empty string if no corresponding activity can be found. You can use this before starting an external application to ensure that the application is installed on the phone.
StartActivity()
Start the activity associated with this component.

BluetoothClient

Picture of Bluetooth Client component

Bluetooth client component

Properties

AddressesAndNames
A list of the addresses and names of paired Bluetooth devices.
Available
Tell whether Bluetooth is available on the Android device.
CharacterEncoding
The character encoding to use when sending and receiving text.
DelimiterByte
The delimiter byte to use when passing a negative number for the numberOfBytes parameter when calling ReceiveText, ReceiveSignedBytes, or ReceiveUnsignedBytes.
Enabled
Tell whether Bluetooth is enabled.
HighByteFirst
Whether 2 and 4 byte numbers should be sent and received with the high (or most significant) byte first. Check the documentation for the device with which your app will be communicating for the appropriate setting. This is also known as big-endian.
IsConnected
Tell whether a Bluetooth connection has been made.

Events

none

Methods

number BytesAvailableToReceive()
Returns an estimate of the number of bytes that can be received without blocking
boolean Connect(text address)
Connect to the Bluetooth device with the specified address and the Serial Port Profile (SPP). Returns true if the connection was successful. The address parameter can contain extra characters after the MAC address if there is a space immediately after the MAC address. This means that you may pass an item from the list returned from the AddressesAndNames property without splitting apart the address and the name.
boolean ConnectWithUUID(text address, text uuid)
Connect to the Bluetooth device with the specified address and UUID. Returns true if the connection was successful. The address parameter can contain extra characters after the MAC address if there is a space immediately after the MAC address. This means that you may pass an item from the list returned from the AddressesAndNames property without splitting apart the address and the name.
Disconnect()
Disconnect from the connected Bluetooth device.
boolean IsDevicePaired(text address)
Checks whether the Bluetooth device with the specified address is paired.
number ReceiveSigned1ByteNumber()
Receive a signed 1-byte number from the connected Bluetooth device.
number ReceiveSigned2ByteNumber()
Receive a signed 2-byte number from the connected Bluetooth device.
number ReceiveSigned4ByteNumber()
Receive a signed 4-byte number from the connected Bluetooth device.
list ReceiveSignedBytes(number numberOfBytes)
Receive multiple signed byte values from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.
text ReceiveText(number numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.
number ReceiveUnsigned1ByteNumber()
Receive an unsigned 1-byte number from the connected Bluetooth device.
number ReceiveUnsigned2ByteNumber()
Receive a unsigned 2-byte number from the connected Bluetooth device.
number ReceiveUnsigned4ByteNumber()
Receive a unsigned 4-byte number from the connected Bluetooth device.
list ReceiveUnsignedBytes(number numberOfBytes)
Receive multiple unsigned byte values from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.
Send1ByteNumber(text number)
Send a 1-byte number to the connected Bluetooth device.
Send2ByteNumber(text number)
Send a 2-byte number to the connected Bluetooth device.
Send4ByteNumber(text number)
Send a 4-byte number to the connected Bluetooth device.
SendBytes(list list)
Send a list of byte values to the connected Bluetooth device.
SendText(text text)
Send text to the connected Bluetooth device.

BluetoothServer

Picture of Bluetooth Server component

Bluetooth server component

Properties

Available: boolean
Tell whether Bluetooth is available on the Android device.
CharacterEncoding: text
The character encoding to use when sending and receiving text.
DelimiterByte: number
The delimiter byte to use when passing a negative number for the numberOfBytes parameter when calling ReceiveText, ReceiveSignedBytes, or ReceiveUnsignedBytes.
Enabled: boolean
Tell whether Bluetooth is enabled.
HighByteFirst: boolean
Whether 2 and 4 byte numbers should be sent and received with the high (or most significant) byte first. Check the documentation for the device with which your app will be communicating for the appropriate setting. This is also known as big-endian.
IsAccepting: boolean
Tell whether this BluetoothServer component is accepting an incoming connection.
IsConnected: boolean
Tell whether a Bluetooth connection has been made.

Events

ConnectionAccepted()
Indicates that a bluetooth connection has been accepted.

Methods

AcceptConnection(text serviceName)
Accept an incoming connection with the Serial Port Profile (SPP).
AcceptConnectionWithUUID(text serviceName, text uuid)
Accept an incoming connection with a specific UUID.
number BytesAvailableToReceive()
Returns an estimate of the number of bytes that can be received without blocking
Disconnect()
Disconnect from the connected Bluetooth device.
number ReceiveSigned1ByteNumber()
Receive a signed 1-byte number from the connected Bluetooth device.
number ReceiveSigned2ByteNumber()
Receive a signed 2-byte number from the connected Bluetooth device.
number ReceiveSigned4ByteNumber()
Receive a signed 4-byte number from the connected Bluetooth device.
list ReceiveSignedBytes(number numberOfBytes)
Receive multiple signed byte values from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.
text ReceiveText(number numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.
number ReceiveUnsigned1ByteNumber()
Receive an unsigned 1-byte number from the connected Bluetooth device.
number ReceiveUnsigned2ByteNumber()
Receive a unsigned 2-byte number from the connected Bluetooth device.
number ReceiveUnsigned4ByteNumber()
Receive a unsigned 4-byte number from the connected Bluetooth device.
list ReceiveUnsignedBytes(number numberOfBytes)
Receive multiple unsigned byte values from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.
Send1ByteNumber(text number)
Send a 1-byte number to the connected Bluetooth device.
Send2ByteNumber(text number)
Send a 2-byte number to the connected Bluetooth device.
Send4ByteNumber(text number)
Send a 4-byte number to the connected Bluetooth device.
SendBytes(list list)
Send a list of byte values to the connected Bluetooth device.
SendText(text text)
Send text to the connected Bluetooth device.
StopAccepting()
Stop accepting an incoming connection.

Web

Non-visible component that provides functions for HTTP GET, POST, PUT, and DELETE requests.

Properties

AllowCookies
Whether the cookies from a response should be saved and used in subsequent requests. Cookies are only supported on Android version 2.3 or greater.
RequestHeaders
The request headers, as a list of two-element sublists. The first element of each sublist represents the request header field name. The second element of each sublist represents the request header field values, either a single value or a list containing multiple values.
ResponseFileName
The name of the file where the response should be saved. If SaveResponse is true and ResponseFileName is empty, then a new file name will be generated.
SaveResponse
Whether the response should be saved in a file.
Url
The URL for the web request.

Events

GotFile(text url, number responseCode, text responseType, text fileName)
Event indicating that a request has finished.
GotText(text url, number responseCode, text responseType, text responseContent)
Event indicating that a request has finished.

Methods

text BuildRequestData(list list)
Converts a list of two-element sublists, representing name and value pairs, to a string formatted as application/x-www-form-urlencoded media type, suitable to pass to PostText.
ClearCookies()
Clears all cookies for this Web component.
Delete()
Performs an HTTP DELETE request using the Url property and retrieves the response.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
Get()
Performs an HTTP GET request using the Url property and retrieves the response.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
text HtmlTextDecode(text htmlText)
Decodes the given HTML text value. HTML character entities such as &amp;, &lt;, &gt;, &apos;, and &quot; are changed to &, <, >, ', and ". Entities such as &#xhhhh, and &#nnnn are changed to the appropriate characters.
any JsonTextDecode(text jsonText)
Decodes the given JSON encoded value to produce a corresponding AppInventor value. A JSON list [x, y, z] decodes to a list (x y z), A JSON object with name A and value B, (denoted as A:B enclosed in curly braces) decodes to a list ((A B)), that is, a list containing the two-element list (A B).
PostFile(text path)
Performs an HTTP POST request using the Url property and data from the specified file.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
PostText(text text)
Performs an HTTP POST request using the Url property and the specified text.
The characters of the text are encoded using UTF-8 encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The responseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
PostTextWithEncoding(text text, text encoding)
Performs an HTTP POST request using the Url property and the specified text.
The characters of the text are encoded using the given encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
PutFile(text path)
Performs an HTTP PUT request using the Url property and data from the specified file.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
PutText(text text)
Performs an HTTP PUT request using the Url property and the specified text.
The characters of the text are encoded using UTF-8 encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The responseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
PutTextWithEncoding(text text, text encoding)
Performs an HTTP PUT request using the Url property and the specified text.
The characters of the text are encoded using the given encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
text UriEncode(text text)
Encodes the given text value so that it can be used in a URL.

© 2014-2016 AppyBuilder

Contact Us