Use socket connections
Although you can implement HTTP over a socket connection, you should use an HTTP connection for the following reasons Socket connections do not support the BlackBerry Mobile Data System features, such as push. Applications that use socket connections typically require significantly more bandwidth than applications that use HTTP connections. Before opening a socket connection, verify that the BlackBerry device is in a wireless coverage area. Use the CoverageInfo class and CoverageStatusListener...
Click one of the following tabs
Summary The Summary view displays general statistics about the system and the garbage collection process. It displays the percentage of time that the JVM spends idle, executing code, and performing quick and full garbage collection processes. The Percent column displays the percent of total JVM running time, including idle and collection times. Methods The Methods view displays a list of modules, sorted either by the information that you are profiling or by the number of times that the...
On the General tab set the following options
The profiler tool calculates the time spent executing bytecode in a method and all methods that the method invokes. The profiler tool calculates the time spent executing bytecode in that method only. The timer stops when a call is made to another method. The profiler tool sorts methods in the profile pane by the number of times the application executed the item. Profiled data select in What to profile The profiler tool sorts methods in the profile pane by the data you choose to profile. The...
Code sample Creating custom buttons
Copyright C 2001-2005 Research In Motion Limited. All rights reserved. package com.rim.samples.docs.custombuttons import net.rim.device.api.ui. import net.rim.device.api.system. CustomButtonField is a class that creates button fields of various shapes. This sample demonstrates how to create custom UI fields. public class CustomButtonField extends Field implements DrawStyle public static final int RECTANGLE 1 public static final int TRIANGLE 2 public static final int OCTAGON 3 Constructs a...
Create custom context menus
Create the custom context menu gt In your field class, create the custom context menu items. items. private Menultem myContextMenultemA new MenuItem _resources, MENUITEM_ONE, 200000, 10 public void run private MenuItem myContextMenuItemB new MenuItem _resources, MENUITEM_ONE, 200000, 10 public void run Provide a context menu. gt In your main application class, override makeContextMenu . protected void makeContextMenu ContextMenu contextMenu Create the application menu. gt In your main...
Create a custom field
Create a custom field. You can only add custom context menu items and custom layouts to a custom field. gt Extend the Field class, or one of its subclasses, implementing the DrawStyle interface to specify the characteristics of the custom field and turn on drawing styles. public class CustomButtonField extends Field implements DrawStyle public static final int RECTANGLE 1 public static final int TRIANGLE 2 public static final int OCTAGON 3 private String _label private int _shape private Font...
Perform one of the following tasks Scw
Load an application .cod file on the BlackBerry Issue a command using the following format javaloader -u load lt .cod file gt For example javaloader.exe -u load MyApplication.cod JavaLoader loads the .cod files listed in the .jad file on the BlackBerry device and stores the .cod files in a CodeModuleGroup. Load application .cod files listed in the same .jad Issue a command using the following format javaloader -u load lt .jad file gt For example javaloader.exe -u load MyApplication.jad...
Square brackets [ indicate inclusive closed range matching
Round brackets indicate exclusive open range matching. Missing lower ranges imply 0. Missing upper ranges imply infinity. For example, 4.0, indicates any version between 4.0 and infinity. The following example prevents modules from loading on versions of the BlackBerry Device Software earlier than version 4.0. lt application id lt application_id gt lt application gt The following example provides alternative modules for different versions of the BlackBerry Device Software. lt application id lt...
Use BlackBerry persistent storage
The BlackBerry persistence model provides a flexible and efficient way to store data. When writing an application specifically for BlackBerry devices, use the BlackBerry persistence model. The BlackBerry persistence model lets you save any Object in the persistent store. As a result, searching for data in the persistent store is faster than searching in the record store model. To store custom object types, the class of the custom type must use the Persistable interface. In the BlackBerry...
Code sample Saving user name and password information
This code sample demonstrates how to create an application for BlackBerry device users that lets them view their current user names and passwords, type new user names and passwords, and save changes. Copyright C 2001-2005 Research In Motion Limited. All rights reserved. package com.rim.samples.docs.userinfo .ui.component. .ui.container. .system. import net.rim.device.ap import net.rim.device.ap import net.rim.device.ap import net.rim.device.ap import net.rim.device.api.util. import j ava.util....
Create custom layout managers
Extend the Manager class or one of its subclasses. class DiagonalManager extends Manager public DiagonalManager long style Override getPreferredWidth so that it returns the preferred field width for the manager. public int getPreferredWidth int width 0 int numberOfFields getFieldCount for int i 0 i lt numberOfFields i width getField i .getPreferredWidth Organize more than one TextField or Manager object. Override the respective getPreferredWidth methods for the TextField or Manager objects....
Use breakpoints
In the breakpoints pane, perform any of the following tasks Execute code and print values to the Output window when code execution reaches a Breakpoint. In the Execute when hit field, type an expression. For example, type System.out.println foo . Open the source code at a set breakpoint. In the Resume if true field, type an expression. When application execution reaches the breakpoint, application execution resumes if the expression evaluates to true. Stop the application after a specific...
Manage persistent data
Each PersistentObject has a unique long key. In the BlackBerry Integrated Development Environment, type a string value, such as Right-click this string and click Convert 'com.rim.samples.docs.userinfo' to long. Include a comment in your code to indicate the string that you used to generate the unique long key. Create a single static PersistentObject. Invoke PersistentStore.getPersistentObject, using the unique long key as a parameter. store PersistentStore.getPersistentObject...
Code sample Creating a custom context menu
Copyright C 2001-2005 Research In Motion Limited. All rights reserved. package com.rim.samples.docs.contextmenus public class ContextMenuSample extends UiApplication implements ContextMenuSampleResource private MyContextField myContextField private static ResourceBundle _resources ResourceBundle.getBundle ContextMenuSampleResource.BUNDLE_ID, public static void main String args ContextMenuSample app new ContextMenuSample app.enterEventDispatcher Inner class to define a new field. private static...
To connect the BlackBerry IDE to a BlackBerry device using a USB port install
Install .debug files on your computer To debug applications using a BlackBerry device, the .debug files in the BlackBerry Integrated Development Environment must match the software version number of the BlackBerry device. BlackBerry device simulator packages contain .debug files for specific BlackBerry devices. 1. Download the BlackBerry device simulator package for your BlackBerry device software version number from the BlackBerry Developer Zone at 2. Connect a BlackBerry device to the...
Respond to UI events
Interpret the status parameter of the navigation methods. Respond to BlackBerry device user interaction. Provide screen navigation when using a FullScreen or Screen. Provice menu support. Provide menu support in an application that uses the TrackwheelClick method of the TrackwheelListener. gt Manage navigation events by extending the net.rim.device.api.ui.Screen class or one of its subclasses and overriding the following navigation methods navigationClick int status, int time navigationUnclick...
Code sample 1
Copyright C 2002-2005 Research In Motion Limited. package com.rim.samples.docs.taskdemo public final class TaskDemo extends UiApplication public static void main String args new TaskDemo .enterEventDispatcher _taskScreen new TaskScreen pushScreen _taskScreen public final static class TaskScreen extends MainScreen private EditField _summary, _note private DateField _due private ObjectChoiceField _priority, _status private SaveMenuItem _saveMenuItem private class SaveMenuItem extends MenuItem...
RAPC accepts the following command line options in the following order
.java A Java source program file that javac must compile. .class A Java .class file that javac has compiled. .jar An archive of files that the compilation set must include. An input file that contains application information. For example, it contains a list of attributes as specified by the MIDP specification. The name of the class containing the application main entry point without this option, RAPC uses the first main String method it finds as the entry point. Specify the name and location...
Respond to deferred events
gt Implement the NotificationsEngineListener interface. private static class ListenerImpl implements NotificationsEngineListener Define behavior if an event is gt Implement deferredEventWasSuperseded . Define behavior if an event is gt Implement deferredEventWasSuperseded . superseded by another event at the public void deferredEventWasSuperseded long sourceID, long eventID, same or higher priority level. Object eventReference, Object context final long _eventID eventID er eventReference...
Activate libMain on startup
gt In your extension of the CryptoSmartCard class, implement the libMain method. Run the libMain method when the 1. Open the BlackBerry Integrated Development Environment. aPPlication starts. 2. Create a new project for the smart card driver. 3. In the Workspace window, right-click the new project. 5. On the Application tab, in the Project type field, type Library. 6. Make sure that the Auto-run on startup check box is selected. 7. In the Startup Tier field, select the 7 Last 3rd party apps...
Code sample
Copyright C 2001-2005 Research In Motion Limited. All rights reserved. package com.rim.samples.docs.notifications import net.rim.device.api.notification. import net.rim.device.api.ui. import net.rim.device.api.ui.component. import net.rim.device.api.ui.container. import net.rim.device.api.system. import net.rim.device.api.util. public class NotificationsDemo extends UiApplication public static final long ID_1 0xdc5bf2f81374095L private long _eventIdGenerator private static Object er public...
Code sample Pushing data to an application that listens on a BlackBerry device
The HTTPPush.java sample application, which uses standard Java , sends a string of text to a listening client application on the BlackBerry device using either a RIM push or a PAP push. The application pushes data based on an email address. To test push applications with the BlackBerry device simulator, define a mapping between the email address and the BlackBerry device simulator PIN 2100000A . The following code sample compiles using J2SE 1.4.2. Copyright C 2001-2004 Research In Motion...
Create a media player
To play audio on a BlackBerry device, use the Mobile Media API to create a media player and then add functionality to it. Create a player for a sequence of tones. gt Use the ToneControl to permit playback of a BlackBerry device user-defined sequence of tones in an unvarying pitch. Tempo is the bpm with 1 beat equal to 1 4 note. You determine the tempo by multiplying the tempo modifier by 4 to keep it within the byte range of 1 to 127. Tempos in the range of 20 bpm to 508 bpm equate to a tempo...
Code sample Using a SyncCollection to back up data over the wireless network
Example package A collection enabled for OTA backup restore. Basically a serially syncable collection with few added interfaces. class OTABackupRestoreContactCollection implements SyncConverter, SyncCollection, OTASyncCapable, CollectionEventSource private static final long PERSISTENT_KEY 0x266babf899b20b56L private static final long AR_KEY 0xef780e08b3a7cf07L private PersistentObject _persist private Vector _contacts private Vector _listeners the persistable object for the contacts the actual...
Use HTTP connections
gt Use the CoverageInfo class and CoverageStatusListener interface of the verify that the BlackBerry device is in a net.rim.device.api.system package to make sure that the BlackBerry device is in a 1. Invoke Connector.openQ, specifying HTTP as the protocol. 2. Cast the returned object as an HttpConnection or a StreamConnection object. HttpConnection conn null String URL conn gt Invoke HttpConnection.setRequestMethodQ. gt Invoke setRequestProperty on the HttpConnection. BlackBerry 3.2.1 gt...
Notify the system when a SyncCollection changes
Use a collection listener to The system invokes to create a notify the system when a CollectionListener for each SyncCollection that the application makes available for wireless SyncCollection changes. backup. 1. Create a private vector object to store the collection of SyncCollection listeners for the application. private Vector _listeners 2. Implement the CollectionListener method, making sure that the method adds a CollectionListener to the vector object. public void addCollectionListener...
Create new messages
Invoke invokeApplication using the APP_TYPE_MESSAGES constant parameter and a new MessageArguments object that uses the ARG_NEW_SMS parameter. new MessageArguments MessageArguments.ARG_NEW_SMS Create a new populated text message. Create and populate a new TextMessage object. MessageConnection mc MessageConnection Connector.open sms TextMessage m TextMessage mc.newMessage MessageConnection.TEXT_MESSAGE m.setAddress sms 5558888 m.setPayloadText An SMS Message for you Invoke invokeApplication...