Use BlackBerry API
Use Java on Blackberry devices
Application Control
The design of the BlackBerry API BlackBerry Java Development Environment (jde) provides a complete set of APIs and tools to develop Java applications running on Blackberry devices.
The BlackBerry device contains a Java me (Java platform Micro Edition) runtime environment based on cldc1.1 and MIDP. Blackberry API extensions provide additional features and are more tightly integrated with blackberry.
You can use cldc/MIDP and blackberry APIs in your application. To enable your applications to run on any device that uses jtwi (Java Technology for wireless industry, Java Technology in the wireless field, you only need to use cldc and MIDP APIs to compile standard MIDP applications.
[If gte vml 1]> Software Components of blackberry handheld devices
To view api reference. Choose Start> program> Research In Motion> BlackBerry jde 4.1.0> API Java Doc reference
The Blackberry apiblackberry API provides a user interface, localization, network, and other functions for accessing BlackBerry features.
Note: access to certain features, such as advanced encryption, synchronization, and additional message APIs are restricted. To use these APIs, you must receive a license from the certification center dedicated to research in motion. For more information, see the BlackBerry Application Developer guide. Volume 1: Basic Volume 2: advanced.
Blackberry API package
Description
Net. Rim. Blackberry. API. Browser
Applications can call the BlackBerry browser. For more information, see BlackBerry Application Developer guide Volume 2: advanced.
Net. Rim. Blackberry. API. Invoke
Allows applications to call BlackBerry applications, such as tasks, messages, memos, and calls. For more information, see BlackBerry Application Developer guide Volume 2: advanced.
Net. Rim. Blackberry. API. Mail
Defines necessary functions to convert the internal rim message system object component into objects compatible with the mail API and portable. At the same time, it also provides the function of sending, receiving, and accessing messages. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. Blackberry. API. Mail. Event
Defines message events and listener interfaces to manage mail events. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. Blackberry. API. menuitem
Allow applications to add custom menu items to BlackBerry applications such as address books, calendars, and messages. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. Blackberry. API. Options
Allow applications to add option entries to the options of Blackberry devices. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. Blackberry. API. PDAP
Allows applications to interact with blackberry personal information management (PIM). Pim includes Address Book, task, and calendar. The MIDP package javax. microedition. Pim provides similar features. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. Blackberry. API. Phone
Provides advanced features for accessing the phone application. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. Blackberry. API. Phone. phonelogs
The access call history function is provided. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. device. API. Bluetooth
Allows BlackBerry applications to communicate with devices that enable bluetooth wireless technology based on a Bluetooth serial port connection. For more information, see "Connect using a Bluetooth serial port" on Page 103 ".
Net. Rim. device. API. browser. Field
Allows the program to display browser fields on the interface. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. device. API. browser. plugin
Allow the program to add additional supported MIME types to the BlackBerry browser. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. device. API. Collection
Net. Rim. device. API. collection. util
Interfaces and interfaces are defined for managing data sets. For more information, see "set" on page 13 ".
Net. Rim. device. API. Compress
Provides the compression class for gzip and zlib data compression. [1]
Net. Rim. device. API. i18n
Provides classes to support localization of applications on Blackberry devices. For more information, see "localized applications" on page 13 ".
Net. Rim. device. API. Io
Provides a custom BlackBerry class library to manage data input and output.
Net. Rim. device. API. Mime
Provides classes that work with mime-encoded data streams.
Net. Rim. device. API. Notification
Provides notifications for triggering events and methods for responding to system and program events. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. device. API. servicebook
Interfaces that allow programs to add, delete, and access service book [2. For more information, see BlackBerry Application Developer guide Volume 2: Advanced
Net. Rim. device. API. System
Provides access system-level functions, including keyboard and pulley event monitors, image creation and support, and application control.
Net. Rim. device. API. UI
Provides enhanced functions to control the BlackBerry user interface, including screen and control layout management, control type support, focus, scrolling, and listener change. For more information, see "User Interface API" on page 39 ".
Net. Rim. device. API. UI. Component
Provides the Interface Component Library for creating the UI program. For more information, see "show user interface components" on page 39 ".
Net. Rim. device. API. UI. Container
Provides a library for creating UI management components. For more information, see "manage user interface components" on page 49 ".
Net. Rim. device. API. UI. Text
Provides a category to filter text strings, including multiple types of data, such as phone numbers or URLs.
Net. Rim. device. API. util
Provides practical methods and interfaces, including arrays, hash tables, and character matching.
Cldc apicldc API package
Description
Java. Io
Provides system input and output of data streams.
Java. Lang
Provides basic Java programming language classes.
Java. Lang. Ref
Provides reference object classes, which support garbage collection to a certain extent.
Java. util
Contains collection classes, time, and a variety of lifecycle classes.
Javax. microedition. Io
Class that contains general connections.
MIDP apimidp API package
Description
Javax. microedition. lcdui
The MIDP User Interface API provides a set of features for the user interface Implementation of the MIDP application.
Javax. microedition. lcdui. Game
Contains the categories that can be used to develop rich game content for Blackberry devices.
Javax. microedition. MIDlet
It defines the interaction between the MIDP application and the environment in which the application runs the program.
Note: during startup, BlackBerry IDE can transmit parameters to a blackberry cldc application.
Javax. microedition. PKI
Defines the certificate used to verify secure connection information.
Javax. microedition. RMS
Provides a mechanism for the MIDlet to store and obtain persistent data.
PDAP apimidp API package
Description
Javax. microedition. Pim
. Provides a standard mechanism to access PIM information.
Compile the source code on the BlackBerry device using Java, package it into a. COD file, load the. COD file to the BlackBerry device, and run it through a virtual machine.
[Img, 13, 13] File: // C:/127e % 7e1/confac % 7e1. zha/locals % 7e1/temp/msohtml1/01/clip_image002.gif [/img] Note :. the COD file name is limited to 128 bytes.
As described in cldc, BlackBerry ide uses a separate VM architecture. To reduce the amount of memory and the processing capability required by Blackberry devices, the partial classification loading process is called pre-verification, which occurs before Java code is loaded to Blackberry. It is automatically verified before the source code is packaged as A. COD file. The prompt that the verification is completed when the class is loaded to the BlackBerry device.
The following restrictions apply to BlackBerry virtual machines as described in cldc1.1:
- No object structure (finalization)
- No user class is loaded
- No reflection, so RMI and Jini network technologies are not supported.
- No NATIVE METHOD)
- Runtime.exe C () does not execute external processes.
The multi-threaded BlackBerry Java environment provides a real multi-threaded environment to run applications. This environment allows multiple applications to run at the same time, allows events to be broadcast to multiple applications, and long operation and listening threads to run behind the scenes.
Persistent data stored in flash memory is permanently saved between Blackberry resetting. One of the following two methods can be used to store data on a BlackBerry device:
- Use MIDP record storage
- Use the BlackBerry persistent Model
For more information about using the BlackBerry API to store persistent data, see BlackBerry Application Developer guide. Volume 1: Basic Volume 2: advanced.
Network Communication BlackBerry jde implements network communication according to midp2.0. It provides a variety of connection options, including the ability to use HTTP Proxy connections to secure connections behind the corporate firewall.
Blackberry jde provides the following connection types:
- Streamconnection interface, including:
1. HTTP Connection)
2. HTTPS connection (httpsconnection Interface)
3. Socket Connection (socketconnection Interface)
4. Secure Socket Connection (secureconnection Interface)
5. A coomconnection interface connecting to the BlackBerry device in sequence)
- Datagram connection (dtagramconnection Interface), including
1. UDP datagram connection (udp1_ramconnection Interface)
The javax. microedition. Io. pushregistry class maintains some inbound connections to BlackBerry devices.
Stream BlackBerry jde provides a standard interface and class for the stream contained in the cldc java. Io package.
Mime Encoding
Blackberry ide provides the mimeinputstream and mimeoutputstream classes to read and write a mime-encoded data stream.
Class
Description
Mimeinputstream
Implement a stream to read a mime message, and then format and decompose the message as part of the message according to the MIME standard.
Mimeoutputstream
Implements an output stream, which can be formatted as part of the output according to the MIME standard. This class will not complete the actual data encoding, so you must write it to the current data stream to encode it.
Compression
In the net. Rim. device. API. Compress package, BlackBerry jde provides classes to read data streams compressed using zlib or gzip. These behaviors are the same as those in the java.util.zip package of java standard.
By default, compression is allowed. Blackberry devices can write valid gzip and zlib files to compress the file content. Decompression is also supported.
Collection BlackBerry ide provides a set of interfaces and classification classes to manage collections on Blackberry devices.
The net. Rim. device. API. Collection package contains many interfaces that define a set of multiple types for certain data types, such as lists, arrays, and mappings. These interfaces define functions similar to the list, set, and map interfaces of the java standard collection framework.
Implement these interfaces in your own class, or use the class used in the net. Rim. device. API. collection. util package.
Vector
The standard Java. util. Vector implements an array of objects whose sizes can be changed. Blackberry jde also provides appropriate classes, such as RIM. device. API. util. intvector and rim. device. API. util. bytevector, to work on the main types. These classes seem to be the same as normal vectors except that they optimize the items inserted at any position. On the contrary, if you use a standard large vector for random changes, a large amount of data will be moved in flash and ram.
List
Blackberry jde provides classes in the net. Rim. device. API. collection. util package to manage the list of elements.
Class
Description
Sortedreadablelist and
Unsortedreadablelist
Use these classes to maintain the list of sorted and unsorted elements. The sortedreadablelist class requires you to use a comparison object to sort the elements in the list. Each element added to the list must be considered valid by the comparison object.
Intsortedreadablelist and longsortedreadablelist
Use these classes to automatically sort the integer list or elements related to the long integer keyword.
Bigsortedreadablelist and bigunsortedreadablelist
These classes are used to store large data sets (greater than 10 or 15 K ). these classes do not store data in an array, so you can make more effective changes to the big data set.
Readablelistcombiner
Use this class to merge two or more readablelist objects and store them as a single readablelist.
Readablelistutil
This class provides some useful methods such as getat () and getindex (). We can use this class to get the number in the read-only list
Hash table
In addition to the standard Java. util. besides hashtable, BlackBerry jde contains specific net. rim. device. API. collection. util. longhashtablecollection class, which provides a set of hash tables that use long integers as keywords. A longhashtablecollection object. The write operation is used as a ing (using a keyword-element pair), and the read operation is used as a ing or as a set (using the set as an array to get data ).
The event listener interface is divided by event type. Each application registers to receive specific types of events. The application event queue then schedules the event to a suitable listener.
The application can implement an appropriate listener interface or rewrite the listener method in various screen objects. Most applications implement the keylistener and trackwheellistener interfaces and register listeners to receive keyboard and pulley events. Keyboard and pulley are the main way for users to interact with applications.
The following event monitors are placed in the net. Rim. device. API. system package.
Listener Interface
Event Type
Alertlistener
Implement interfaces to listen to alert events
Bluetoothserialportlistener
Implement interfaces to listen to Bluetooth serial port events, such as opening a Bluetooth serial port connection as a server or client.
Globaleventlistener
Implement interfaces to listen to global events that can be broadcast to all applications.
Holsterlistener
Implement interfaces to listen to set events, such as inserting and removing BlackBerry devices from the set.
Ioportlistener
Implements interface listening for I/O port events.
Keylistener
Monitors Keyboard Events through interfaces, such as holding down or releasing a key.
Realtimeclocklistener
This interface is used to monitor real-time clock events, such as clock updates.
Serialportlistener
This interface is used to listen for serialized port events. For example, for a BlackBerry device that has been connected to a computer serial port, a change in the connection status when data is being sent to the serialized port.
Systemlistener
This interface is implemented to monitor system events, such as changes to the Battery status and power supply.
Trackwheellistener
This interface monitors pulley events, such as holding and holding the pulley.
Usbportlistener
This interface monitors USB port events. For example, for a BlackBerry device that has been connected to the USB port of the computer, data is being sent to the USB port connection status.
The net. Rim. device. API. system package class provides the ability to access system resources on Java VMS and BlackBerry devices.
Obtain signal information
Radioinfo provides access signal status information.
Obtain device information
The deviceinfo class can access the information of the following BlackBerry devices:
- Battery power supply and status
- Blackerry device number
- Idle Time
- Platform version
System Event Notification to users
When an event, such as a new message arrives, alert allows applications to notify users.
Monitor memory usage
Use a static method provided by the memory class to obtain VM memory usage statistics.
Many practical methods of the memory class return a memorystats object. Use the practical method provided by the memorystats class to obtain detailed information about the memory and available storage space on the BlackBerry device.
Log events
Eventlogger allows applications to store event logs in persistent storage. When the BlackBerry device maintains the event queue and logs are full on the current day, the earliest events are deleted and new events are added. You can press the Alt + lglg key to view the system event logs of the BlackBerry device.
The tool BlackBerry jde provides a set of utilities in the net. Rim. device. API. util package. Many of these classes provide features similar to those in the java standard version.
- The comparator interface defines the sequential methods on the object set.
- Arrays provides methods to operate arrays, such as sorting, searching, and viewing arrays as a list.
- The bitset class maintains the bit set.
The net. Rim. device. API. util package contains multiple classes to manage data sets of specific types, including vectors, hash tables, mappings, and stacks.
Application Control application control allows the system administrator to perform the following operations:
- Control internal connections (connections behind the company firewall)
- Control external connections
- Control local connections (sequential and USB connections)
- Key store)
- Controls access to special APIs.
- Prevent third-party applications from being stored on Blackberry devices.
For more information, see Application Management in the BlackBerry Enterprise Server handheld management guide.
Restricted access APIs, classes, and methods
Applications that use the following restricted APIs, classes, and methods can be loaded to BlackBerry devices. However, if they access an API that is not controlled by an application, A controlledaccessexception or noclassdeffounderror exception is thrown during running.
Class, method, or API
Default Value
Application menu item API (net. Rim. Blackberry. API. menuitem)
Allow
Bluetooth API (net. Rim. device. API. Bluetooth)
Allow
Connector. open () (javax. microedition. Io)
Prompt
Note: internal and external connections are managed by different application control policies.
Devicekeystore class (net. Rim. device. API. crypto. keystore)
Allow
Eventinjector class (net. Rim. device. API. System)
Not Allowed
HTTP filter API (net. Rim. device. API. Io. http)
Not Allowed
Notification API (net. Rim. device. API. Notification)
Allow
Electricity API and call API (used to call telephone applications) (net. Rim. Blackberry. API. Phone and net. Rim. Blackberry. API. Invoke)
Allow (default, user prompt)
Call log API (net. Rim. Blackberry. API. Phone. phonelogs)
Allow (default, user prompt)
Pim API (net. Rim. Blackberry. API. PDAP)
Allow
Runtimestore class (net. Rim. device. API. System)
Allow
SerialPort class (net. Rim. device. API. System)
Allow
Session class (net. Rim. Blackberry. API. Mail)
Allow
Stringpatternrepository class (net. Rim. device. API. util)
Allow
Usbport class (net. Rim. device. API. System)
Allow
[1] Why does BlackBerry need to compress data? It is very simple, that is, to reduce the space occupied by data. The best example is to send an email by BEs.
[2] service agreement, service book, is a very important concept in BlackBerry use. The function is the service you subscribe to. For example, if you subscribe to the MMS function, it will appear on your BlackBerry handheld device. Translator's note.