Android Programming Press on the image to return to the main documentation page.

Core

List of types:

Application
AttributedString
Bit
Colors
DateTime
Exception
Font
Keywords
LayoutValues
NativeObject
Notification
String
StringBuilder
Timer
WeakRef

Application

Application is a special singleton object that allows you to handle application related events and
holds other application related methods.
The events can only be handled in the main module. The subs prefix should be Application.
The Start event is raised when the application starts. Nav is the default navigation controller.
The Active event is raised when the application becomes active. It is usually raised immediately after Start event and after resuming from the background.
The InActive event is raised when the applications becomes inactive.
This happens when there is an interruption such as a phone call or before the Background event.
The Background event is raised when the process is moved to the background. You should expect the process to be killed a few seconds after this event.
The Foreground event is raised when the app returns to the foreground after it was in the background (assuming that the process was not killed).
The OpenUrl event is raised when another app has called OpenUrl with a scheme that this app has registered.

Events:

Start (Nav As NavigationController)
Active
Inactive
Background
OpenUrl (Url As String, Data As Object, SourceApplication As String) As Boolean
Foreground
ReceiveLocalNotification (LN As Notification)
PushToken (Success As Boolean, Token() As Byte)
RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)

Members:


  ApplicationIconBadgeNumber As Int

  CanOpenURL (Url As String) As Boolean

  ClearLocalNotifications

  GetScheduledNotifications As List

  IdleTimerDisabled As Boolean

  iPadDevice As Boolean [read only]

  Is64BitProcess As Boolean [read only]

  IsInitialized As Boolean

  IsSimulator As Boolean

  KeyController As Object

  LaunchOptions As Map

  NetworkActivityIndicatorVisible As Boolean

  OpenURL (Url As String) As Boolean

  OpenURLAsync (Url As String)

  OSVersion As String [read only]

  RegisterForRemoteNotifications

  RegisterUserNotifications (Badge As Boolean, Sound As Boolean, Alert As Boolean)

  Tag As Object

Members description:

ApplicationIconBadgeNumber As Int
Gets or sets the app icon badge number. You need to call RegisterUserNotifications before setting this property.
CanOpenURL (Url As String) As Boolean
Returns true if there is an app that can open the given url.
Starting from iOS 9 you need to use the #QueriesScheme to list the schemes that will be passed to this method.
ClearLocalNotifications
Clears all scheduled local notifications.
GetScheduledNotifications As List
Returns a list with the scheduled local notifications.
IdleTimerDisabled As Boolean
If true then the screen will not be locked automatically even if the user is not interacting with it,
as long as the application is in the foreground.
iPadDevice As Boolean [read only]
Returns true if the current device is an iPad device.
Is64BitProcess As Boolean [read only]
Returns true if the current process is a 64 bit process.
IsInitialized As Boolean
Tests whether this object was initialized.
IsSimulator As Boolean
KeyController As Object
Gets or sets the root controller. You can use this property to switch to a different controller.
LaunchOptions As Map
Returns a Map with data passed to the app during launch (if there is such data).
NetworkActivityIndicatorVisible As Boolean
Gets or sets whether the network activity indicator (in the top bar) is visible.
OpenURL (Url As String) As Boolean
Sends the Url to the system. If there is an app registered to the Url scheme then the app will be started.
OpenURLAsync (Url As String)
Calls OpenUrl from a background thread. This is useful as OpenURL can sometimes take several seconds to complete.
OSVersion As String [read only]
Returns a string describing the current version.
RegisterForRemoteNotifications
RegisterUserNotifications (Badge As Boolean, Sound As Boolean, Alert As Boolean)
Requests the user permission to use one of more of the notifications features.
You must call this method before registering a local notification or setting the ApplicationIconBadgeNumber.
Tag As Object
Gets or sets the Tag object. This is a placeholder for any object you like to tie to this object.

AttributedString

A String with formatting attributes.
Note that an AttributedString cannot be used instead of String unless the method explicitly expects an AttributedString.

Events:

None

Members:


  Initialize (Text As String, Font As Font, Color As Int)

  IsInitialized As Boolean

  Tag As Object

  ToString As String

Members description:

Initialize (Text As String, Font As Font, Color As Int)
Initializes an AttributesString with the given Text, Font and Color.
IsInitialized As Boolean
Tests whether this object was initialized.
Tag As Object
Gets or sets the Tag object. This is a placeholder for any object you like to tie to this object.
ToString As String
Returns a regular string.

Bit

A predefined object containing bitwise related methods.

Events:

None

Members:


  And (N1 As Int, N2 As Int) As Int

  FMod (N1 As Double, N2 As Double) As Double

  InputStreamToBytes (In As InputStream) As Byte()

  Not (N As Int) As Int

  Or (N1 As Int, N2 As Int) As Int

  ParseInt (Value As String, Radix As Int) As Int

  ShiftLeft (N As Int, Shift As Int) As Int

  ShiftRight (N As Int, Shift As Int) As Int

  UnsignedShiftRight (N As Int, Shift As Int) As Int

  Xor (N1 As Int, N2 As Int) As Int

Members description:

And (N1 As Int, N2 As Int) As Int
Returns the bitwise AND of the two values.
FMod (N1 As Double, N2 As Double) As Double
Computes the floating point remainder of N1 / N2.
InputStreamToBytes (In As InputStream) As Byte()
Reads the data from the input stream and writes it into an array of bytes.
The input stream is automatically closed at the end.
Not (N As Int) As Int
Returns the bitwise complement of the given value.
Or (N1 As Int, N2 As Int) As Int
Returns the bitwise OR of the two values.
ParseInt (Value As String, Radix As Int) As Int
Parses Value as an integer using the specified radix.
Radix - Should be between 2 to 36.
ShiftLeft (N As Int, Shift As Int) As Int
Shifts N left.
Shift - Number of positions to shift.
ShiftRight (N As Int, Shift As Int) As Int
Shift N right.
Keeps the original value sign.
Shift - Number of positions to shift.
UnsignedShiftRight (N As Int, Shift As Int) As Int
Shift N right.
Shifts zeroes in the leftmost positions.
Shift - Number of positions to shift.
Xor (N1 As Int, N2 As Int) As Int
Returns the bitwise XOR of the two values.

Colors

A predefined object containing color constants.
Colors are represented as Int values. The first byte is the alpha level and the other three values are the R, G and B components.

Events:

None

Members:


  ARGB (A As Int, R As Int, G As Int, B As Int) As Int

  Black As Int [read only]

  Blue As Int [read only]

  Cyan As Int [read only]

  DarkGray As Int [read only]

  Gray As Int [read only]

  Green As Int [read only]

  LightGray As Int [read only]

  Magenta As Int [read only]

  Red As Int [read only]

  RGB (R As Int, G As Int, B As Int) As Int

  Transparent As Int [read only]

  White As Int [read only]

  Yellow As Int [read only]

Members description:

ARGB (A As Int, R As Int, G As Int, B As Int) As Int
Similar to RGB. Allows you to set the alpha level.
Black As Int [read only]
Blue As Int [read only]
Cyan As Int [read only]
DarkGray As Int [read only]
Gray As Int [read only]
Green As Int [read only]
LightGray As Int [read only]
Magenta As Int [read only]
Red As Int [read only]
RGB (R As Int, G As Int, B As Int) As Int
Returns an integer value representing the color built from the three components.
Each component should be a value between 0 to 255 (inclusive). The alpha is set to 255.
Transparent As Int [read only]
White As Int [read only]
Yellow As Int [read only]

DateTime

Date and time related methods.
Date and time values are stored as ticks. Ticks represent the number of milliseconds since January 1, 1970 00:00:00 UTC.
This value is too large to be stored in an Int variable. It should only be stored in a Long variable.
DateUtils module should be used for time calculations when working with intervals larger than hours.

Events:

None

Members:


  Add (Ticks As Long, Years As Int, Months As Int, Days As Int) As Long

  Date (Ticks As Long) As String

  DateFormat As String

  DateParse (Date As String) As Long

  DateTimeParse (Date As String, Time As String) As Long

  DeviceDefaultDateFormat As String [read only]

  DeviceDefaultTimeFormat As String [read only]

  GetDayOfMonth (Ticks As Long) As Int

  GetDayOfWeek (Ticks As Long) As Int

  GetDayOfYear (Ticks As Long) As Int

  GetHour (Ticks As Long) As Int

  GetMinute (Ticks As Long) As Int

  GetMonth (Ticks As Long) As Int

  GetSecond (Ticks As Long) As Int

  GetTimeZoneOffsetAt (Ticks As Long) As Double

  GetYear (Ticks As Long) As Int

  Now As Long [read only]

  SetTimeZone (OffsetHours As Double)

  TicksPerDay As Long [read only]

  TicksPerHour As Long [read only]

  TicksPerMinute As Long [read only]

  TicksPerSecond As Long [read only]

  Time (Ticks As Long) As String

  TimeFormat As String

  TimeZoneOffset As Double [read only]

Members description:

Add (Ticks As Long, Years As Int, Months As Int, Days As Int) As Long
Returns a ticks value which is the result of adding the specified time spans to the given ticks value.
Pass negative values to substract.
In most cases it is better to use DateUtils.AddPeriod.
Date (Ticks As Long) As String
Returns a string representation of the date (which is stored as ticks).
Example:
Log("Today is: " & DateTime.Date(DateTime.Now))
DateFormat As String
Gets or sets the process date format.
The default format is MM/dd/yyyy (04/23/2002 for example).
The patterns are the same as in B4A and B4J.
Supported formats
DateParse (Date As String) As Long
Parses the given date string and returns its ticks representation.
Example:
Dim SomeTime As Long = DateTime.DateParse("02/23/2007")
DateTimeParse (Date As String, Time As String) As Long
Parses the given date and time strings and returns the ticks representation.
DeviceDefaultDateFormat As String [read only]
Returns the device default date format.
DeviceDefaultTimeFormat As String [read only]
Returns the device default time format.
GetDayOfMonth (Ticks As Long) As Int
Returns the day of month component from the ticks value.
Values are between 1 to 31.
GetDayOfWeek (Ticks As Long) As Int
Returns the day of week component from the ticks value.
Values are between 1 to 7, where 1 means Sunday.
GetDayOfYear (Ticks As Long) As Int
Returns the day of year component from the ticks value.
Values are between 1 to 366.
GetHour (Ticks As Long) As Int
Returns the hour component from the ticks value.
Values are between 0 to 23.
GetMinute (Ticks As Long) As Int
Returns the minutes within hour component from the ticks value.
Values are between 0 to 59.
GetMonth (Ticks As Long) As Int
Returns the month component from the ticks value. Values are between 1 to 12.
GetSecond (Ticks As Long) As Int
Returns the seconds within minute component from the ticks value.
Values are between 0 to 59.
GetTimeZoneOffsetAt (Ticks As Long) As Double
Returns the offset measured in hours from UTC at the specified date.
GetYear (Ticks As Long) As Int
Returns the year component from the ticks value.
Now As Long [read only]
Returns the current time represented as the number of milliseconds since 1/1/1970 00:00 UTC.
SetTimeZone (OffsetHours As Double)
Sets the process time zone.
TicksPerDay As Long [read only]
Number of ticks per 24 hours. In almost all cases it is better to use DateUtils module when working with days.
Note that there are days with less or more than 24 hours.
TicksPerHour As Long [read only]
Number or ticks per hour.
TicksPerMinute As Long [read only]
Number of ticks per minute.
TicksPerSecond As Long [read only]
Number of ticks per second (1000).
Time (Ticks As Long) As String
Returns a string representation of the time (which is stored as ticks).
Example:
Log("The time now is: " & DateTime.Time(DateTime.Now))
TimeFormat As String
Gets or sets the process time format.
The default format is HH:mm:ss (23:45:12 for example).
The patterns are the same as in B4A and B4J.
Supported formats
TimeZoneOffset As Double [read only]
Returns the current offset measured in hours from UTC.

Exception

An object holding information about an exception.
LastException will hold the last exception caught in a Try / Catch block.

Events:

None

Members:


  Code As Int [read only]

  Description As String [read only]

  Domain As String [read only]

  IsInitialized As Boolean

  Message As String [read only]

  Tag As Object

Members description:

Code As Int [read only]
Returns the error code number.
Description As String [read only]
Returns the error description.
Domain As String [read only]
Returns the error domain.
IsInitialized As Boolean
Tests whether this object was initialized.
Message As String [read only]
Same as Description (same API as in B4A and B4J).
Tag As Object
Gets or sets the Tag object. This is a placeholder for any object you like to tie to this object.

Font

Font is a predefined object that provides access to the device installed fonts.

Events:

None

Members:


  AvailableNames As String()

  CreateFontAwesome (Size1 As Float) As Font

  CreateMaterialIcons (Size1 As Float) As Font

  CreateNew (Size1 As Float) As Font

  CreateNew2 (Name As String, Size1 As Float) As Font

  CreateNewBold (Size1 As Float) As Font

  CreateNewItalic (Size1 As Float) As Font

  DEFAULT As Font [read only]

  DEFAULT_BOLD As Font [read only]

  DEFAULT_ITALIC As Font [read only]

  IsInitialized As Boolean

  Name As String [read only]

  Size As Float [read only]

  Tag As Object

Members description:

AvailableNames As String()
Returns an array of strings with all available fonts names.
CreateFontAwesome (Size1 As Float) As Font
Creates a new FontAwesome font.
CreateMaterialIcons (Size1 As Float) As Font
Creates a new Material Icons font.
CreateNew (Size1 As Float) As Font
Creates a new font with the specified size (based on the default font).
CreateNew2 (Name As String, Size1 As Float) As Font
Creates a new font with the specified size and font name.
CreateNewBold (Size1 As Float) As Font
Creates a new bold font with the specified size (based on the default font).
CreateNewItalic (Size1 As Float) As Font
Creates a new italic font with the specified size (based on the default font).
DEFAULT As Font [read only]
Returns the default font.
DEFAULT_BOLD As Font [read only]
Returns the default bold font.
DEFAULT_ITALIC As Font [read only]
Returns the default italic font.
IsInitialized As Boolean
Tests whether this object was initialized.
Name As String [read only]
Returns the font name.
Size As Float [read only]
Returns the font size.
Tag As Object
Gets or sets the Tag object. This is a placeholder for any object you like to tie to this object.

Keywords


Events:

None

Members:


  Abs (Number As Double) As Double

  ACos (Value As Double) As Double

  ACosD (Value As Double) As Double

  Array

  Asc (Char As Char) As Int

  ASin (Value As Double) As Double

  ASinD (Value As Double) As Double

  ATan (Value As Double) As Double

  ATan2 (Y As Double, X As Double) As Double

  ATan2D (Y As Double, X As Double) As Double

  ATanD (Value As Double) As Double

  BytesToString (Data() As Byte, StartOffset As Int, Length As Int, CharSet As String) As String

  CallSub (Component As Object, Sub As String) As Object

  CallSub2 (Component As Object, Sub As String, Argument As Object) As Object

  CallSub3 (Component As Object, Sub As String, Argument1 As Object, Argument2 As Object) As Object

  CallSubDelayed (Component As Object, Sub As String)

  CallSubDelayed2 (Component As Object, Sub As String, Argument As Object)

  CallSubDelayed3 (Component As Object, Sub As String, Argument1 As Object, Argument2 As Object)

  Catch

  cE As Double [read only]

  Ceil (Number As Double) As Double

  Chr (UnicodeValue As Int) As Char

  Colors As Colors

  Continue

  Cos (Radians As Double) As Double

  CosD (Degrees As Double) As Double

  cPI As Double [read only]

  CreateMap

  CRLF As String [read only]

  Dim

  DipToCurrent (Length As Int) As Int

  Exit

  False As Boolean [read only]

  File As Object

  Floor (Number As Double) As Double

  Font As Font

  For

  GetDeviceLayoutValues As LayoutValues

  GetType (Object As Object) As String

  If

  Is As Boolean

  IsDevTool (ToolName As String) As Boolean

  IsNumber (Value As String) As Boolean

  LastException As Exception

  LoadBitmap (Dir As String, FileName As String) As Bitmap

  Log (Text As String)

  Logarithm (Number As Double, Base As Double) As Double

  LogColor (Message As String, Color As Int)

  Max (Number1 As Double, Number2 As Double) As Double

  Me () As Object

  Min (Number1 As Double, Number2 As Double) As Double

  Msgbox (Message As String, Title As String)

  Msgbox2 (EventName As String, Message As String, Title As String, Buttons As List) As Object

  Not (Value As Boolean) As Boolean

  Null As Object [read only]

  NumberFormat (Number As Double, MinimumIntegers As Int, MaximumFractions As Int) As String

  NumberFormat2 (Number As Double, MinimumIntegers As Int, MaximumFractions As Int, MinimumFractions As Int, GroupingUsed As Boolean) As String

  PerXToCurrent (Percentage As Float) As Float

  PerYToCurrent (Percentage As Float) As Float

  Power (Base As Double, Exponent As Double) As Double

  QUOTE As String [read only]

  Regex As Object

  Return

  Rnd (Min As Int, Max As Int) As Int

  Round (Number As Double) As Double

  Select

  Sender () As Object

  SetDebugAutoFlushLogs (Enabled As Boolean)

  Sin (Angle As Double) As Double

  SinD (Degrees As Double) As Double

  Sleep (Milliseconds As Int)

  SmartStringFormatter (Format As String, Value As Object) As String

  Sqrt (Value As Double) As Double

  Sub

  SubExists (Component As Object, Sub As String, NumberOfArguments As Int) As Boolean

  TAB As String [read only]

  Tan (Radians As Double) As Double

  TanD (Degrees As Double) As Double

  True As Boolean [read only]

  Try

  Type

  Until

  While

Members description:

Abs (Number As Double) As Double
Returns the absolute value.
ACos (Value As Double) As Double
Returns the angle measured with radians.
ACosD (Value As Double) As Double
Returns the angle measured with degrees.
Array
Creates a single dimension array of the specified type.
The syntax is: Array As type (list of values).
Example:
Dim Days() As String
Days = Array As String("Sunday", "Monday", ...)
Asc (Char As Char) As Int
Returns the unicode code point of the give character.
ASin (Value As Double) As Double
Returns the angle measured with radians.
ASinD (Value As Double) As Double
Returns the angle measured with degrees.
ATan (Value As Double) As Double
Returns the angle measured with radians.
ATan2 (Y As Double, X As Double) As Double
Returns the angle measured with radians.
ATan2D (Y As Double, X As Double) As Double
Returns the angle measured with degrees.
ATanD (Value As Double) As Double
Returns the angle measured with degrees.
BytesToString (Data() As Byte, StartOffset As Int, Length As Int, CharSet As String) As String
Decodes the given bytes array as a string.
Data - The bytes array.
StartOffset - The first byte to read.
Length - Number of bytes to read.
CharSet - The name of the character set.
Example:
Dim s As String = BytesToString(Buffer, 0, Buffer.Length, "UTF-8")
CallSub (Component As Object, Sub As String) As Object
Dynamically calls a sub. This can be used to implement events.
In most cases you should not use CallSub and instead directly call the target sub.
Nothing happens if the sub does not exist.
Component - The target module or instance.
Sub - The sub name.
CallSub2 (Component As Object, Sub As String, Argument As Object) As Object
Similar to CallSub. Calls a sub with a single argument.
CallSub3 (Component As Object, Sub As String, Argument1 As Object, Argument2 As Object) As Object
Similar to CallSub. Calls a sub with two arguments.
CallSubDelayed (Component As Object, Sub As String)
Similar to CallSub.
Sends a message to the message queue. When the message is processed the sub is called.
CallSubDelayed2 (Component As Object, Sub As String, Argument As Object)
Similar to CallSubDelayed. Calls a sub with a single argument.
CallSubDelayed3 (Component As Object, Sub As String, Argument1 As Object, Argument2 As Object)
Similar to CallSubDelayed. Calls a sub with two arguments.
Catch
Any exception thrown inside a try block will be caught in the catch block.
Call LastException to get the caught exception.
Syntax:
Try
...
Catch
...
End Try
cE As Double [read only]
e (natural logarithm base) constant.
Ceil (Number As Double) As Double
Returns the smaller whole number that is larger or equal to the specified number.
Chr (UnicodeValue As Int) As Char
Returns the character that is represented by the given unicode value.
Colors As Colors
Colors related methods.
Continue
Stops executing the current iteration and continues with the next one.
Cos (Radians As Double) As Double
Calculates the trigonometric cosine function. Angle measured in radians.
CosD (Degrees As Double) As Double
Calculates the trigonometric cosine function. Angle measured in degrees.
cPI As Double [read only]
PI constant.
CreateMap
Creates a Map with the given key / value pairs.
The syntax is: CreateMap(key1: value1, key2: value2, ...)
Example:
Dim m As Map = CreateMap("January": 1, "February": 2)
CRLF As String [read only]
New line character. The value of Chr(10).
Dim
Declares a variable.
Syntax:
Declare a single variable:
Dim variable name [As type] [= expression]
The default type is String.

Declare multiple variables. All variables will be of the specified type.
Dim variable1 [= expression], variable2 [= expression], ..., [As type]
Note that the shorthand syntax only applies to Dim keyword.
Example:Dim a = 1, b = 2, c = 3 As Int

Declare an array:
Dim variable(Rank1, Rank2, ...) [As type]
Example:Dim Days(7) As String
The actual rank can be omitted for zero length arrays.
DipToCurrent (Length As Int) As Int
The logical scale of iOS device is always 1.0. This method returns the value of Length.
Exit
Exits the most inner loop.
Note that Exit inside a Select block will exit the Select block.
False As Boolean [read only]
File As Object
Files related methods.
Floor (Number As Double) As Double
Returns the largest whole number that is smaller or equal to the specified number.
Font As Font
Font related methods.
For
Syntax:
For variable = value1 To value2 [Step interval]
...
Next
If the iterator variable was not declared before it will be of type Int.

Or:
For Each variable As type In collection
...
Next
Examples:
For i = 1 To 10
Log(i) 'Will print 1 to 10 (inclusive).
Next
For Each n As Int In Numbers 'an array
Sum = Sum + n
Next

Note that the loop limits will only be calculated once before the first iteration.
GetDeviceLayoutValues As LayoutValues
Returns the device LayoutValues.
Example:
Log(GetDeviceLayoutValues)
GetType (Object As Object) As String
Returns the Objective C type of the given object.
If
Single line:
If condition Then true-statement [Else false-statement]
Multiline:
If condition Then
statement
Else If condition Then
statement
...
Else
statement
End If
Is As Boolean
Tests whether the object is of the given type.
Note that when a number is converted to object it might change its type to a different type of number
(for example a Byte might be converted to an Int).
Example:
For Each v As View in Page1.RootPanel.GetAllViewsRecursive
If v Is Button Then
Dim b As Button = v
b.Color = Colors.Blue
End If
Next
IsDevTool (ToolName As String) As Boolean
Returns true if ToolName equals "B4i".
IsNumber (Value As String) As Boolean
Tests whether the specified string can be safely parsed as a number.
LastException As Exception
Returns the last exception that was caught.
LoadBitmap (Dir As String, FileName As String) As Bitmap
Loads a bitmap. Note that the file system is case sensitive.
Log (Text As String)
Logs a message. The message will be visible in the Logs tab in the IDE (in debug mode).
Logarithm (Number As Double, Base As Double) As Double
Returns the logarithm of the given Number.
LogColor (Message As String, Color As Int)
Similar to Log. Sets the message color.
Max (Number1 As Double, Number2 As Double) As Double
Returns the larger number between the two numbers.
Me () As Object
Returns a reference to the current instance or module.
Min (Number1 As Double, Number2 As Double) As Double
Returns the smaller number between the two numbers.
Msgbox (Message As String, Title As String)
Shows a message box with the given message and title.
The dialog is not a modal dialog. The code will not block.
Msgbox2 (EventName As String, Message As String, Title As String, Buttons As List) As Object
Shows a message box with the given message and title.
The dialog is not a modal dialog. The code will not block.
EventName - Sets the sub that will handle the Click event.
Message - The dialog message.
Title - The dialog title.
Buttons - A List of strings that will be used as buttons.

Example:
Msgbox2("Msg", "Do you want to do delete document?", "Title", Array ("Yes", "No"))
Wait For Msg_Click (ButtonText As String)
If ButtonText = "Yes" Then
'delete document
End If

This method returns an object that can be used as the Sender Filter parameter with Wait For.
Not (Value As Boolean) As Boolean
Inverts the value of the given boolean.
Null As Object [read only]
NumberFormat (Number As Double, MinimumIntegers As Int, MaximumFractions As Int) As String
Converts the specified number to a string.
The string will include at least Minimum Integers and at most Maximum Fractions digits.
Example:
Log(NumberFormat(12345.6789, 0, 2)) '"12,345.68"
Log(NumberFormat(1, 3, 0)) '"001"
NumberFormat2 (Number As Double, MinimumIntegers As Int, MaximumFractions As Int, MinimumFractions As Int, GroupingUsed As Boolean) As String
Converts the specified number to a string.
The string will include at least Minimum Integers, at most Maximum Fractions digits and at least Minimum Fractions digits.
GroupingUsed - Whether to group every three integers.
Example:
Log(NumberFormat2(12345.67, 0, 3, 3, False)) '"12345.670"
PerXToCurrent (Percentage As Float) As Float
Returns the actual size of the given percentage of the page width.
This value is only exact while inside the Page_Resize event.
In other cases it is relative to the screen width.
PerYToCurrent (Percentage As Float) As Float
Returns the actual size of the given percentage of the page height.
This value is only exact while inside the Page_Resize event.
In other cases it is relative to the screen height.
Power (Base As Double, Exponent As Double) As Double
Returns the Base value raised to the Exponent power.
QUOTE As String [read only]
Quote character - Chr(34).
Regex As Object
Regular expressions related methods.
Return
Returns from the current sub and optionally returns the given value.
Syntax: Return [value]
Rnd (Min As Int, Max As Int) As Int
Returns a random integer between Min (inclusive) and Max (exclusive).
Round (Number As Double) As Double
Returns the whole number closest to the given number. In most cases it is better to use NumberFormat or NumberFormat2 instead.
Select
Compares a single value to multiple values.
Example:
Dim value As Int = 7
Select value
Case 1
Log("One")
Case 2, 4, 6, 8
Log("Even")
Case 3, 5, 7, 9
Log("Odd")
Case Else
Log("Larger than 9")
End Select
Sender () As Object
Returns the object that raised the event. Only valid while inside the event sub.
Example:
Sub Button1_Click
Dim b As Button = Sender
b.Text = "I've been clicked"
End Sub
SetDebugAutoFlushLogs (Enabled As Boolean)
This method has no effect in Release mode.
If True then a short pause will be applied after each log message.
This is useful for debugging hard crashes that prevent the logs from being printed.
Sin (Angle As Double) As Double
Calculates the trigonometric sine function. Angle measured in radians.
SinD (Degrees As Double) As Double
Calculates the trigonometric sine function. Angle measured in degrees.
Sleep (Milliseconds As Int)
Pauses the current sub execution and resumes it after the specified time.
SmartStringFormatter (Format As String, Value As Object) As String
Internal keyword used by the Smart String literal.
Sqrt (Value As Double) As Double
Returns the positive square root.
Sub
Declares a sub with the parameters and return type.
Syntax: Sub name [(list of parameters)] [As return-type]
Parameters include name and type.
The lengths of arrays dimensions should not be included.
Example:
Sub MySub (FirstName As String, LastName As String, Age As Int, OtherValues() As Double) As Boolean
...
End Sub

In this example OtherValues is a single dimension array.
The return type declaration is different than other declarations as the array parenthesis follow the type and not
the name (which does not exist in this case).
SubExists (Component As Object, Sub As String, NumberOfArguments As Int) As Boolean
Checks whether the given component has a sub with the given number of arguments.
TAB As String [read only]
Tab character.
Tan (Radians As Double) As Double
Calculates the trigonometric tangent function. Angle measured in radians.
TanD (Degrees As Double) As Double
Calculates the trigonometric tangent function. Angle measured in degrees.
True As Boolean [read only]
Try
Any exception thrown inside a try block will be caught in the catch block.
Call LastException to get the caught exception.
Syntax:
Try
...
Catch
...
End Try
Type
Declares a structure.
Can only be used inside sub Globals or sub Process_Globals.
Syntax:
Type type-name (field1, field2, ...)
Fields include name and type.
Example:
Type MyType (Name As String, Items(10) As Int)
Dim a, b As MyType
a.Initialize
a.Items(2) = 123
Until
Loops until the condition is true.
Syntax:
Do Until condition
...
Loop
While
Loops while the condition is true.
Syntax:
Do While condition
...
Loop

LayoutValues


Events:

None

Members:


  DeviceApproximateScreenSize As Double [read only]

  Height As Int [read only]

  NonnormalizedScale As Float [read only]

  Scale As Float [read only]

  Width As Int [read only]

Members description:

DeviceApproximateScreenSize As Double [read only]
Returns the device approximate screen size measured in inches.
Height As Int [read only]
Returns the (normalized) height.
NonnormalizedScale As Float [read only]
Returns the non-normalized scale.
Scale As Float [read only]
Returns 1 as this is the scale is normalized automatically by the OS.
Width As Int [read only]
Returns the (normalized) width.

NativeObject

NativeObject is similar to B4A/B4J JavaObject. It allows you to call native methods and get or set fields.
Note that only Objective C APIs can be used. C APIs cannot be called dynamically.

Events:

Event (Args() As Object) As Object

Members:


  ArrayToNSData (Arr() As Byte) As Object

  AsBoolean As Boolean

  AsNumber As Object

  AsString As String

  ColorToUIColor (Color As Int) As Object

  CreateBlock (SubName As String, NumberOfParameters As Int, Delayed As Boolean) As Object

  GetField (Field As String) As NativeObject

  Initialize (ClassName As String) As NativeObject

  IsInitialized As Boolean

  MakePoint (X As Float, Y As Float) As Object

  MakeRange (StartLocation As Int, Length As Int) As Object

  MakeRect (X As Float, Y As Float, Width As Float, Height As Float) As Object

  MakeSize (Width As Float, Height As Float) As Object

  NSDataToArray (Data As Object) As Byte()

  RunMethod (MethodName As String, Params() As Object) As NativeObject

  RunMethodWithBlocks (MethodName As String, Params() As Object) As NativeObject

  SetField (FieldName As String, Value As Object)

  Tag As Object

  UIColorToColor (UIColor As Object) As Int

Members description:

ArrayToNSData (Arr() As Byte) As Object
Converts an array of bytes to NSData object.
AsBoolean As Boolean
Returns the wrapped object as a Boolean value.
AsNumber As Object
Returns the wrapped object as a numeric value.
AsString As String
Returns the wrapped object as a String value.
ColorToUIColor (Color As Int) As Object
Converts B4i color value to UIColor.
CreateBlock (SubName As String, NumberOfParameters As Int, Delayed As Boolean) As Object
Creates a block that raises the given sub.
SubName - The event prefix. The sub signature should be: SubName_Event (Args() As Object) As Object.
NumberOfParameters - The number of parameters passed to the block. Should be between 0 to 2.
Delayed - Whether the event is raised immediately or it is sent to the message queue.
GetField (Field As String) As NativeObject
Gets the value of the given property or field.
Initialize (ClassName As String) As NativeObject
Initializes a new object and sets it to reference the given class.
IsInitialized As Boolean
Tests whether this object was initialized.
MakePoint (X As Float, Y As Float) As Object
Creates a CGPoint struct.
MakeRange (StartLocation As Int, Length As Int) As Object
Creates a NSRange struct.
MakeRect (X As Float, Y As Float, Width As Float, Height As Float) As Object
Creates a CGRect struct.
MakeSize (Width As Float, Height As Float) As Object
Creates a CGSize struct.
NSDataToArray (Data As Object) As Byte()
Converts an NSData object to an array of bytes.
RunMethod (MethodName As String, Params() As Object) As NativeObject
Runs the given method. Params can be Null if there are no parameters.
Note that a method name is the full name with the colons.
RunMethodWithBlocks (MethodName As String, Params() As Object) As NativeObject
Similar to RunMethod. Runs a method that expects a block.
SetField (FieldName As String, Value As Object)
Sets the value of the given property or field.
Tag As Object
Gets or sets the Tag object. This is a placeholder for any object you like to tie to this object.
UIColorToColor (UIColor As Object) As Int
Converts a UIColor to B4i color value.

Notification

Notification object allows you to schedule local notifications.
You need to call App.RegisterUserNotifications before you create a local notification.

Events:

None

Members:


  AlertBody As String

  Cancel

  IconBadgeNumber As Int

  Initialize (FireDate As Long)

  IsInitialized As Boolean

  NotificationTag As String

  PlaySound As Boolean

  Register

  Tag As Object

Members description:

AlertBody As String
Gets or sets the notification message.
Cancel
Cancel a scheduled notification.
IconBadgeNumber As Int
Gets or sets the app icon badge number.
Initialize (FireDate As Long)
Initializes the notification and sets the fire date.
IsInitialized As Boolean
Tests whether this object was initialized.
NotificationTag As String
Gets or sets the tag string that will be tied to this notification.
This value will be available when the user clicks on the notification.
PlaySound As Boolean
Gets or sets whether the notification will play a sound.
Register
Schedules the notification.
Tag As Object
Gets or sets the Tag object. This is a placeholder for any object you like to tie to this object.

String


Events:

None

Members:


  CharAt (Index As Int) As Char

  CompareTo (Other As String) As Int

  Contains (SearchFor As String) As Boolean

  EndsWith (Suffix As String) As Boolean

  EqualsIgnoreCase (Other As String) As Boolean

  GetBytes (CharSet As String) As Byte()

  IndexOf (SearchFor As String) As Int

  IndexOf2 (SearchFor As String, Index As Int) As Int

  LastIndexOf (SearchFor As String) As Int

  LastIndexOf2 (SearchFor As String, Index As Int) As Int

  Length As Int

  MeasureHeight (Font As Font) As Float

  MeasureWidth (Font As Font) As Float

  Replace (Target As String, Replacement As String) As String

  StartsWith (Prefix As String) As Boolean

  SubString (BeginIndex As Int) As String

  SubString2 (BeginIndex As Int, EndIndex As Int) As String

  ToLowerCase As String

  ToUpperCase As String

  Trim As String

Members description:

CharAt (Index As Int) As Char
Returns the character at the given index.
CompareTo (Other As String) As Int
Lexicographically compares the two strings.
Returns a value less than 0 if the current string precedes Other.
Returns 0 if both strings are equal.
Returns a value larger than 0 if the current string comes after Other.
Note that upper case characters precede lower case characters.
Examples:
"abc".CompareTo("da") ' < 0
"abc".CompareTo("Abc") ' > 0
"abc".CompareTo("abca")' < 0
Contains (SearchFor As String) As Boolean
Tests whether the string contains the given string parameter.
EndsWith (Suffix As String) As Boolean
Returns true if this string ends with the given Suffix.
EqualsIgnoreCase (Other As String) As Boolean
Returns true if both strings are equal ignoring their case.
GetBytes (CharSet As String) As Byte()
Encodes the string into a new array of bytes.
You can use ByteToString keyword to convert an array of bytes (encoded string) to a string.
Example:
Dim Data() As Byte = "Some string".GetBytes("UTF8")
IndexOf (SearchFor As String) As Int
Returns the index of the first occurrence of the specified string in this string.
Returns -1 if the string is not found.
IndexOf2 (SearchFor As String, Index As Int) As Int
Similar to IndexOf. Starts the search from Index.
LastIndexOf (SearchFor As String) As Int
Returns the index of the first occurrence of the specified string in this string.
The search starts at the end of this string and advances to the beginning.
LastIndexOf2 (SearchFor As String, Index As Int) As Int
Similar to LastIndexOf. The search starts at the given index.
Length As Int
Returns the string length.
MeasureHeight (Font As Font) As Float
Returns the height of this string drawn with the given font.
MeasureWidth (Font As Font) As Float
Returns the width of this string drawn with the given font.
Replace (Target As String, Replacement As String) As String
Returns a new string resulting from the replacement of all the occurrences of Target with Replacement.
StartsWith (Prefix As String) As Boolean
Returns true if this string starts with the given Prefix.
SubString (BeginIndex As Int) As String
Returns a new string which is a substring of the original string.
The new string will include the character at BeginIndex and will extend to the end of the string.
Example:
"012345".SubString(2) 'Returns "2345"
SubString2 (BeginIndex As Int, EndIndex As Int) As String
Returns a new string which is a substring of the original string.
The new string will include the character at BeginIndex and will extend to the character as EndIndex (exclusive).
Example:
"012345".SubString(2, 4) 'Returns "23"
ToLowerCase As String
Returns a new string which is the result of lower casing this string.
ToUpperCase As String
Returns a new string which is the result of upper casing this string.
Trim As String
Returns a copy of the original string without any leading or trailing white spaces.

StringBuilder

A mutable string, unlike regular strings which are immutable.
StringBuilder allows you to quickly concatenate strings and modify the content.

Events:

None

Members:


  Append (Text As String) As StringBuilder

  Initialize

  Insert (Offset As Int, Text As String) As StringBuilder

  IsInitialized As Boolean

  Length As Int [read only]

  Remove (StartOffset As Int, EndOffset As Int) As StringBuilder

  Tag As Object

  ToString As String

Members description:

Append (Text As String) As StringBuilder
Appends the specified text to the StringBuilder and returns the current StringBuilder.
Initialize
Insert (Offset As Int, Text As String) As StringBuilder
Inserts the given Text at the specified Offset and returns the current StringBuilder.
IsInitialized As Boolean
Tests whether this object was initialized.
Length As Int [read only]
Returns the string length.
Remove (StartOffset As Int, EndOffset As Int) As StringBuilder
Removes the characters between StartOffset (inclusive) and EndOffset (exclusive) and returns the current StringBuilder.
Tag As Object
Gets or sets the Tag object. This is a placeholder for any object you like to tie to this object.
ToString As String
Converts the StringBuilder content to a regular string.

Timer

A timer raises the Tick event after each interval.
The event is raised on the main thread.

Events:

Tick

Members:


  Enabled As Boolean

  Initialize (EventName As String, Interval As Long)

  Interval As Long

  IsInitialized As Boolean

Members description:

Enabled As Boolean
Gets or sets whether the timer is enabled. New timers are not enabled.
Initialize (EventName As String, Interval As Long)
Initializes the timer and set the sub that will handle the tick event.
The timer is disabled until the Enabled property is set to true.
Interval - Timer interval in milliseconds.
Interval As Long
Gets or sets the interval, measured in milliseconds.
IsInitialized As Boolean
Tests whether the object was initialized.

WeakRef

WeakRef object holds a weak reference to another object. This is useful to avoid a reference cycle memory leaks.

Events:

None

Members:


  Value As Object

Members description:

Value As Object
Gets or sets the weak referenced object. The value will be "Nulled" automatically when there are no more strong references to the target object.
Top